y
y
yq
v4.x
Search
⌃K
v4.x
y
y
yq
v4.x
Search
⌃K
yq
How It Works
Upgrading from V3
Commands
Evaluate
Evaluate All
Shell Completion
Operators
Add
Alternative (Default value)
Anchor and Alias Operators
Array to Map
Assign (Update)
Boolean Operators
Collect into Array
Column
Comment Operators
Compare Operators
Contains
Create, Collect into Object
Date Time
Delete
Divide
Document Index
Encode / Decode
Entries
Env Variable Operators
Equals
Eval
File Operators
Filter Operator
Flatten
Group By
Has
Keys
Length
Line
Load
Map
Modulo
Multiply (Merge)
Parent
Path
Pick
Pipe
Recursive Descent (Glob)
Reduce
Reverse
Select
Shuffle
Slice Array
Sort
Sort Keys
Split into Documents
String Operators
Style
Subtract
Tag
Traverse (Read)
Union
Unique
Variable Operators
With
Usage
Output format
Working with CSV, TSV
Working with JSON
Working with Properties
Working with XML
Working with TOML
Front Matter
Split into multiple files
GitHub Action
Tips, Tricks, Troubleshooting
Github Page
Powered By GitBook

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
- 5
then
yq 'shuffle' sample.yml
will output
- 5
- 2
- 4
- 1
- 3

Shuffle array in place

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
Previous
Select
Next
Slice Array
Last modified 1mo ago
Copy link
On this page
Shuffle array
Shuffle array in place