I am having issues reading values from yaml file when there's dot in the key name
i.e.
a:
b.c: 2
reading the a
key works fine with cat mytext.yaml | yq r - a
however, when I tried reading a.b.c
but it doesn't give any output.
I tried escaping the dot symbol, but doesn't give any ouput
Anything I am missing here?
On v4 onwards, you could simply use the new syntax notation, i.e.
echo 'a:
b.c: 2' | yq e '.a."b.c"' -
In mikefarah/yq, you can use the quotes ".."
, to preserve the field containing .
in your path expression as explained in the documentation Nested special characters
echo 'a:
b.c: 2' | yq r - 'a."b.c"'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With