yq
Yq is a command line tool that stands for "YAML processors and jq-like tool for YAML and JSON data." It is built specifically for working with YAML files and provides a convenient and powerful way to interact with YAML data from the command line. Yq is inspired by jq, a popular command line tool for processing JSON data. It allows you to merge, filter, convert, and otherwise manipulate YAML files easily. Yq supports both reading and writing YAML, making it versatile for various tasks. You can use yq to extract specific data from a YAML file based on filters, making it a handy tool for data extraction and analysis. The tool also supports converting YAML to JSON and vice versa, providing flexibility in working with different data formats. Yq has a simple yet intuitive syntax that makes it accessible to beginners while also providing advanced features for experienced users. It is written in Go and available as a single executable, making it easy to install and use across different operating systems. Overall, yq is a valuable tool for anyone working with YAML files and needing to automate or streamline their data processing tasks from the command line.
List of commands for yq:
-
yq:tldr:38feb yq: Output the first element in a YAML file that contains only an array (v3).$ yq read ${filename-yaml} '[0]'try on your machineexplain this command
-
yq:tldr:699dd yq: Output a YAML file, in pretty-print format (v4+).$ yq eval ${filename-yaml}try on your machineexplain this command
-
yq:tldr:7aa22 yq: Merge two files and print to `stdout` (v4+).$ yq eval-all 'select(filename == "${filename1-yaml}") * select(filename == "${filename2-yaml}")' ${filename1-yaml} ${filename2-yaml}try on your machineexplain this command
-
yq:tldr:8366a yq: Merge two files and print to `stdout` (v3).$ yq merge ${filename1-yaml} ${filename2-yaml} --colorstry on your machineexplain this command
-
yq:tldr:b7ff6 yq: Set (or overwrite) a key to a value in a file (v4+).$ yq eval '.${key} = "${value}"' --inplace ${filename-yaml}try on your machineexplain this command
-
yq:tldr:c8061 yq: Output a YAML file, in pretty-print format (v3).$ yq read ${filename-yaml} --colorstry on your machineexplain this command
-
yq:tldr:dc364 yq: Set (or overwrite) a key to a value in a file (v3).$ yq write --inplace ${filename-yaml} '${key}' '${value}'try on your machineexplain this command
-
yq:tldr:f0110 yq: Output the first element in a YAML file that contains only an array (v4+).$ yq eval '.[0]' ${filename-yaml}try on your machineexplain this command