Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to escape dash in jq call

How to escape dash in jq call?

cat afile | jq -r .commit-sha1

So the dash is being interpreted in some way. How to escape it? I tried wrap with "

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

For such keys, you need to quote the key, but the quotes must also be quoted so that they aren’t removed by the shell prior to running jq.

jq -r '."commit-sha1"'

The abbreviated from .foo is for "simple, identifier-like keys", according to the man page.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading