After the success of the jq
- tool for parsing and manipulating JSON-Data someone wrote a tool called yq
, which aims to be the same for YAML, what jq is for JSON. Seems to work fine. I'll definitely give it a chance in future.
Example YAML-File:
--- !ruby/object:Puppet::Node::Facts
values:
processors:
models:
- "Intel(R) Xeon(R) CPU E5620 @ 2.40GHz"
count: 1
physicalcount: 1
kernel: Linux
architecture: x86_64
hardwaremodel: x86_64
operatingsystem: CentOS
os:
name: CentOS
family: RedHat
release:
major: "6"
minor: "10"
full: "6.10"
processor0: "Intel(R) Xeon(R) CPU E5620 @ 2.40GHz"
yq - Usage:
# Command
yq -r .values.os.family data.yaml
# Output
RedHat
It's already available via repository in newer versions of major linux distributions
See also:
Yq