Reverses the order of the items in an array
Given a sample.yml file of:
- 1 - 2 - 3
then
yq 'reverse' sample.yml
will output
- 3 - 2 - 1
Use sort with reverse to sort in descending order.
- a: banana - a: cat - a: apple
Last updated 3 years ago
Was this helpful?
yq 'sort_by(.a) | reverse' sample.yml
- a: cat - a: banana - a: apple