y
y
yq
Search…
Reverse
Reverses the order of the items in an array
Note that versions prior to 4.18 require the 'eval/e' command to be specified.
yq e <exp> <file>

Reverse

Given a sample.yml file of:
- 1
- 2
- 3
then
yq 'reverse' sample.yml
will output
- 3
- 2
- 1

Sort descending by string field

Use sort with reverse to sort in descending order.
Given a sample.yml file of:
- a: banana
- a: cat
- a: apple
then
yq 'sort_by(.a) | reverse' sample.yml
will output
- a: cat
- a: banana
- a: apple
Last modified 6mo ago
Copy link
On this page
Reverse
Sort descending by string field