There are some shell workarounds to parse yaml
files:
yq
You may use yq
, a command line YAML processor built on top of jq
.
You can download it and find documentation at http://mikefarah.github.io/yq/.
niet
Another tool is openuado/niet
Niet is like xmllint or jq but for YAML and JSON data - you can use it to slice and filter and map and transform structured data.
You can easily retrieve data by using simple expressions or using xpath advanced features to access non-trivial data.
You can easily convert YAML format into JSON format and vice versa.
bash-yaml
for pure bash
For pure bash
you can try:
jasperes/bash-yaml
Read a yaml file and create variables in bash
Simple 41-lines-of-bash script uses only sed
and awk
to parse yaml
-file and create variables from it.
mrbaseman/parse_yaml
parse_yaml
provides a bash function that allows parsing simple YAML files. The output is shell code that defines shell variables which contain the parsed values. bash
doesn't support multidimensional arrays. Therefore a separate variable is created for each value, and the name of the variable consists of the names of all levels in the yaml file, glued together with a separator character which defaults to _