Reverse
Reverses the order of the items in an array
Reverse
Given a sample.yml file of:
- 1
- 2
- 3then
yq 'reverse' sample.ymlwill output
- 3
- 2
- 1Sort descending by string field
Use sort with reverse to sort in descending order.
Given a sample.yml file of:
- a: banana
- a: cat
- a: applethen
yq 'sort_by(.a) | reverse' sample.ymlwill output
- a: cat
- a: banana
- a: appleLast updated
Was this helpful?