yq/pkg/yqlib/doc/operators/collect-into-array.md
2022-10-25 12:47:13 +11:00

426 B

Collect into Array

This creates an array using the expression between the square brackets.

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