yq - Parse YAML on the command line using Mike Farah's yq CLI

by
Jeremy Canfield |
Updated: November 25 2024
| yq articles
Mike Farah's yq CLI and jq are similar, where Mike Farah's yq CLI is meant to parse YAML and jq is meant to parse JSON.
If you do not have Mike Farah's yq CLI installed on your Linux system, check out my article FreeKB - yq - Install Mike Farah's yq CLI.
Here are some examples of how to parse YAML as stdin on the command line.
~]$ echo 'foo': 'hello' | yq eval . -
foo: hello
~]$ echo 'foo': 'hello' | yq eval .foo -
hello
~]$ echo {'foo': 'hello', 'bar': 'world'} | yq eval . -
{foo: hello, bar: world}
~]$ echo {'foo': 'hello', 'bar': 'world'} | yq eval .bar -
world
~]$ echo {'items': [{'foo':'hello', 'bar':'world'}]} | yq eval .items[] -
{'foo:hello': '', 'bar:world': ''}
Did you find this article helpful?
If so, consider buying me a coffee over at