//home | tags | archives | about | grosu.nl | eulinux.org | RSS Feed

Manipulating yaml data on the CLI

floyd - Sun 06 October 2019 - yaml, ruby, cli

If you have ruby and jq installed, it's as easy as adding a function to your ~/.bashrc (or .kshrc):

function yaml2json()
{
    ruby -ryaml -rjson -e \
         'puts JSON.pretty_generate(YAML.load(ARGF))' $*
}

And then yaml2json document.yaml|jq ...