I'm curious whether I can replace file name with a string when using -f
option of jq
.
When I do
$ jq -nf <(echo \"hello world\")
it correctly outputs
"hello world"
But when I try
$ jq -nf <<<$'\"hello world\"'
this fails with error
jq: Could not open .: It's a directory
Anyone knows how to make this work? I know this is more of a bash
question than jq
.
$ jq '.' <<< '"hello world"'
works though.
Thanks.
CodePudding user response:
You can use /dev/stdin
to represent standard input as a file:
jq -nf /dev/stdin <<<$'\"hello world\"'
echo \"hello world\" | jq -nf /dev/stdin