yq/pkg/yqlib/doc/Length.md
Mike Farah f7f8bed955 wip
2020-12-27 09:55:21 +11:00

612 B

Returns the lengths of the nodes. Length is defined according to the type of the node.

String length

returns length of string

Given a sample.yml file of:

a: cat
'': null

then

yq eval '.a | length' sample.yml

will output

3

Map length

returns number of entries

Given a sample.yml file of:

a: cat
c: dog
'': null

then

yq eval 'length' sample.yml

will output

3

Array length

returns number of elements

Given a sample.yml file of:

- 2
- 4
- 6
- 8

then

yq eval 'length' sample.yml

will output

4