y
y
yq
Search…
Evaluate
Evaluates the given expression against each yaml document in each file, in sequence

Usage:

1
yq eval [expression] [yaml_file1]... [flags]
Copied!
Aliases: eval, e
Note that you can pass in - as a filename to pipe from STDIN.

Examples:

1
# runs the expression against each file, in series
2
yq e '.a.b | length' f1.yml f2.yml
3
4
# '-' will pipe from STDIN
5
cat file.yml | yq e '.a.b' f1.yml - f2.yml
6
7
# prints out the file
8
yq e sample.yaml
9
cat sample.yml | yq e
10
11
# prints a new yaml document
12
yq e -n '.a.b.c = "cat"'
13
14
# updates file.yaml directly
15
yq e '.a.b = "cool"' -i file.yaml
Copied!

Flags:

1
-h, --help help for eval
2
-C, --colors force print with colors
3
-e, --exit-status set exit status if there are no matches or null or false is returned
4
-I, --indent int sets indent level for output (default 2)
5
-i, --inplace update the yaml file inplace of first yaml file given.
6
-M, --no-colors force print with no colors
7
-N, --no-doc Don't print document separators (---)
8
-n, --null-input Don't read input, simply evaluate the expression given. Useful for creating yaml docs from scratch.
9
-j, --tojson output as json. Set indent to 0 to print json in one line.
10
-v, --verbose verbose mode
Copied!
Last modified 29d ago
Copy link