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:
a: catthen
yq '.a | length' sample.ymlwill output
3null length
Given a sample.yml file of:
a: nullthen
yq '.a | length' sample.ymlwill output
0Map length
returns number of entries
Given a sample.yml file of:
a: cat
c: dogthen
yq 'length' sample.ymlwill output
2Array length
returns number of elements
Given a sample.yml file of:
- 2
- 4
- 6
- 8then
yq 'length' sample.ymlwill output
4Last updated
Was this helpful?