JQ 1.5.3 prints help when I try to pipe output:
$ export ZK=x
$ echo '{"jvm":{"value":"x"}}' | jq -c --arg ZK="$ZK" 'select(.jvm.value | contains("$ZK"))' | tail -n 1
jq - commandline JSON processor [version 1.5]
Usage: jq [options] <jq filter> [file...]
...
But this behaviour happens only when I used --arg
option. It does not happen when I use hardcoded values:
$ echo '{"jvm":{"value":"x"}}' | jq -c 'select(.jvm.value | contains("x"))' | tail -n 1
{"jvm":{"value":"x"}}
It does not happen also when using --arg
option without piping output, i.e., printing to a standard output:
$ echo '{"jvm":{"value":"x"}}' | jq -c --arg ZK="$ZK" 'select(.jvm.value | contains("$ZK"))'
{"jvm":{"value":"x"}}
I have read about similar issue on GitHub, but their workaround did not help.
echo '{"jvm":{"value":"x"}}' | jq -c --arg ZK="$ZK" 'select(.jvm.value | contains("$ZK"))' | jq . -M | tail -n 1
How can I pipe output of jq tool?