mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-15 07:38:14 +00:00
574 B
574 B
Collect into Array
This creates an array using the expression between the square brackets.
{% hint style="warning" %} Note that versions prior to 4.18 require the 'eval/e' command to be specified.
yq e <exp> <file>
{% endhint %}
Collect empty
Running
yq --null-input '[]'
will output
[]
Collect single
Running
yq --null-input '["cat"]'
will output
- cat
Collect many
Given a sample.yml file of:
a: cat
b: dog
then
yq '[.a, .b]' sample.yml
will output
- cat
- dog