Shuffle
Shuffles an array. Note that this command does not use a cryptographically secure random number generator to randomise the array order.
Given a sample.yml file of:
- 1
- 2
- 3
- 4
- 5
then
yq 'shuffle' sample.yml
will output
- 5
- 2
- 4
- 1
- 3
Given a sample.yml file of:
cool:
- 1
- 2
- 3
- 4
- 5
then
yq '.cool |= shuffle' sample.yml
will output
cool:
- 5
- 2
- 4
- 1
- 3
Last modified 6mo ago