Shuffle
Shuffles an array. Note that this command does not use a cryptographically secure random number generator to randomise the array order.
Shuffle array
Given a sample.yml file of:
- 1
- 2
- 3
- 4
- 5then
yq 'shuffle' sample.ymlwill output
- 5
- 2
- 4
- 1
- 3Shuffle array in place
Given a sample.yml file of:
cool:
  - 1
  - 2
  - 3
  - 4
  - 5then
yq '.cool |= shuffle' sample.ymlwill output
cool:
  - 5
  - 2
  - 4
  - 1
  - 3Last updated
Was this helpful?