y
y
yq
Search…
y
y
yq
v4.x
yq
How It Works
Upgrading from V3
Commands
Evaluate
Evaluate All
Shell Completion
Operators
Add
Alternative (Default value)
Anchor and Alias Operators
Assign (Update)
Boolean Operators
Collect into Array
Column
Comment Operators
Compare Operators
Contains
Create, Collect into Object
Date Time
Delete
Document Index
Encode / Decode
Entries
Env Variable Operators
Equals
Eval
File Operators
Flatten
Group By
Has
Keys
Length
Line
Load
Map
Multiply (Merge)
Parent
Path
Pick
Pipe
Recursive Descent (Glob)
Reduce
Reverse
Select
Sort
Sort Keys
Split into Documents
String Operators
Style
Subtract
Tag
Traverse (Read)
Union
Unique
Variable Operators
With
Usage
Output format
Working with CSV, TSV
Working with JSON
Working with Properties
Working with XML
Front Matter
Split into multiple files
GitHub Action
Tips, Tricks, Troubleshooting
Github Page
Powered By
GitBook
Length
Returns the lengths of the nodes. Length is defined according to the type of the node.
Note that versions prior to 4.18 require the 'eval/e' command to be specified.
yq e <exp> <file>
String length
returns length of string
Given a sample.yml file of:
1
a
:
cat
Copied!
then
1
yq
'.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
'.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
'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
'length'
sample.yml
Copied!
will output
1
4
Copied!
Previous
Keys
Next
Line
Last modified
4mo ago
Copy link
Contents
String length
null length
Map length
Array length