My test json file is as follows:
{
"server":"xxx",
"cert":"line1\nline2",
"security/path": "/var/log/systems.log"
}
I would like to filter by key security/path, and below commands all don't work.
jq .security/path test.json
jq: error: path/0 is not defined at <top-level>, line 1:
.security/path
jq: 1 compile error
jq '.security/path' test.json has same result.
trto remove the double quotes, you would usejqwith its-roption. That way you get the properly decoded string fromjq(which would make a difference, for example, to thecertstring in the question, which contains an encoded newline). Note too that your answer seems to be identical to the older answer from steeldriver, and that you're using broken JSON whichjqwill not parse as an example. – Kusalananda Oct 18 '22 at 17:59