github.com/Racer159/jackal@v0.32.7-0.20240401174413-0bd2339e4f2e/docs/2-the-jackal-cli/100-cli-commands/jackal_tools_yq_eval.md (about) 1 # jackal tools yq eval 2 <!-- Auto-generated by hack/gen-cli-docs.sh --> 3 4 (default) Apply the expression to each document in each yaml file in sequence 5 6 ## Synopsis 7 8 yq is a portable command-line data file processor (https://github.com/mikefarah/yq/) 9 See https://mikefarah.gitbook.io/yq/ for detailed documentation and examples. 10 11 # Evaluate Sequence ## 12 This command iterates over each yaml document from each given file, applies the 13 expression and prints the result in sequence. 14 15 ``` 16 jackal tools yq eval [expression] [yaml_file1]... [flags] 17 ``` 18 19 ## Examples 20 21 ``` 22 23 # Reads field under the given path for each file 24 jackal tools yq e '.a.b' f1.yml f2.yml 25 26 # Prints out the file 27 jackal tools yq e sample.yaml 28 29 # Pipe from STDIN 30 # use '-' as a filename to pipe from STDIN 31 cat file2.yml | jackal tools yq e '.a.b' file1.yml - file3.yml 32 33 # Creates a new yaml document 34 # Note that editing an empty file does not work. 35 jackal tools yq e -n '.a.b.c = "cat"' 36 37 # Update a file inplace 38 jackal tools yq e '.a.b = "cool"' -i file.yaml 39 40 ``` 41 42 ## Options 43 44 ``` 45 -h, --help help for eval 46 ``` 47 48 ## Options inherited from parent commands 49 50 ``` 51 -C, --colors force print with colors 52 --csv-auto-parse parse CSV YAML/JSON values (default true) 53 --csv-separator char CSV Separator character (default ,) 54 -e, --exit-status set exit status if there are no matches or null or false is returned 55 --expression string forcibly set the expression argument. Useful when yq argument detection thinks your expression is a file. 56 --from-file string Load expression from specified file. 57 -f, --front-matter string (extract|process) first input as yaml front-matter. Extract will pull out the yaml content, process will run the expression against the yaml content, leaving the remaining data intact 58 --header-preprocess Slurp any header comments and separators before processing expression. (default true) 59 -I, --indent int sets indent level for output (default 2) 60 -i, --inplace update the file in place of first file given. 61 -p, --input-format string [auto|a|yaml|y|json|j|props|p|csv|c|tsv|t|xml|x|base64|uri|toml|lua|l] parse format for input. (default "auto") 62 --lua-globals output keys as top-level global variables 63 --lua-prefix string prefix (default "return ") 64 --lua-suffix string suffix (default ";\n") 65 --lua-unquoted output unquoted string keys (e.g. {foo="bar"}) 66 -M, --no-colors force print with no colors 67 -N, --no-doc Don't print document separators (---) 68 -0, --nul-output Use NUL char to separate values. If unwrap scalar is also set, fail if unwrapped scalar contains NUL char. 69 -n, --null-input Don't read input, simply evaluate the expression given. Useful for creating docs from scratch. 70 -o, --output-format string [auto|a|yaml|y|json|j|props|p|csv|c|tsv|t|xml|x|base64|uri|toml|shell|s|lua|l] output format type. (default "auto") 71 -P, --prettyPrint pretty print, shorthand for '... style = ""' 72 --properties-array-brackets use [x] in array paths (e.g. for SpringBoot) 73 --properties-separator string separator to use between keys and values (default " = ") 74 -s, --split-exp string print each result (or doc) into a file named (exp). [exp] argument must return a string. You can use $index in the expression as the result counter. 75 --split-exp-file string Use a file to specify the split-exp expression. 76 --string-interpolation Toggles strings interpolation of \(exp) (default true) 77 --tsv-auto-parse parse TSV YAML/JSON values (default true) 78 -r, --unwrapScalar unwrap scalar, print the value with no quotes, colors or comments. Defaults to true for yaml (default true) 79 -v, --verbose verbose mode 80 --xml-attribute-prefix string prefix for xml attributes (default "+@") 81 --xml-content-name string name for xml content (if no attribute name is present). (default "+content") 82 --xml-directive-name string name for xml directives (e.g. <!DOCTYPE thing cat>) (default "+directive") 83 --xml-keep-namespace enables keeping namespace after parsing attributes (default true) 84 --xml-proc-inst-prefix string prefix for xml processing instructions (e.g. <?xml version="1"?>) (default "+p_") 85 --xml-raw-token enables using RawToken method instead Token. Commonly disables namespace translations. See https://pkg.go.dev/encoding/xml#Decoder.RawToken for details. (default true) 86 --xml-skip-directives skip over directives (e.g. <!DOCTYPE thing cat>) 87 --xml-skip-proc-inst skip over process instructions (e.g. <?xml version="1"?>) 88 --xml-strict-mode enables strict parsing of XML. See https://pkg.go.dev/encoding/xml for more details. 89 ``` 90 91 ## SEE ALSO 92 93 * [jackal tools yq](jackal_tools_yq.md) - yq is a lightweight and portable command-line data file processor.