y
y
yq
Search…
Length
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:
1
a: cat
Copied!
then
1
yq eval '.a | length' sample.yml
Copied!
will output
1
3
Copied!

null length

Given a sample.yml file of:
1
a: null
Copied!
then
1
yq eval '.a | length' sample.yml
Copied!
will output
1
0
Copied!

Map length

returns number of entries
Given a sample.yml file of:
1
a: cat
2
c: dog
Copied!
then
1
yq eval 'length' sample.yml
Copied!
will output
1
2
Copied!

Array length

returns number of elements
Given a sample.yml file of:
1
- 2
2
- 4
3
- 6
4
- 8
Copied!
then
1
yq eval 'length' sample.yml
Copied!
will output
1
4
Copied!
Last modified 2mo ago