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

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter 9e5a49 in the box below so that we can be sure you are a human.