Jq: Redirect output to a file and able to silence output

Created on 30 Aug 2014  Â·  7Comments  Â·  Source: stedolan/jq

In shell scripting it seems it would be useful to have an option to dump the output to file a via cmdline option, thus avoiding redirection errors / complexity in scripts. On the shell simple pipes work well, but can be cumbersome in larger scripts
--output-file or something similar

With the --exit-status feature this last release a --silent-output or --quiet option would help in scripting as well. In the case where just validation is required.

thanks for the great tool

feature request

Most helpful comment

I'd also like a command line option to silence any output, -q and perhaps --quiet. I'd want to use it together with the -e option. Or would it perhaps make sense to make -e always quiet?

jq -eq '.action == "destroy"' && echo "DESTROY!!!!"

All 7 comments

Another reason this feature is a must have: this is in 1.5 impossible to filter from/to the same file:
jq '.' myfile.json>myfile.json
is currently failing at least under centos, as it generates an empty output file.
Would it be possible with this new option from 1.6 ?
cheers

I'd also like a command line option to silence any output, -q and perhaps --quiet. I'd want to use it together with the -e option. Or would it perhaps make sense to make -e always quiet?

jq -eq '.action == "destroy"' && echo "DESTROY!!!!"

So the first is actually a side effect of your shell. They create and empty
the target file before setting up the pipes. This means that by the time jq
gets to read your file, it is empty. We had a setting like what you wanted
once, but it caused more subtle issues.

I'm not sure what behavior you intend to gain from a -q option. If you're
looking to not output any text, this could be done by redirecting stdin and
stdout to /dev/null jq -e '.action == "destroy"' >/dev/null 2>/dev/null

On Fri, May 20, 2016, 16:46 Christian Pekeler [email protected]
wrote:

I'd also like a command line option to silence any output, -q and perhaps
--quiet. I'd want to use it together with the -e option. Or would it
perhaps make sense to make -e always quiet?

jq -eq '.action == "destroy"' && echo "DESTROY!!!!"

—
You are receiving this because you are subscribed to this thread.

Reply to this email directly or view it on GitHub
https://github.com/stedolan/jq/issues/565#issuecomment-220714399

Just redirect output to whatever file or /dev/null in the shell.

@stedolan I get a Segmentation Fault on Windows when doing this.

@jkstrauss As in #1180?

@nicowilliams Yes.

Was this page helpful?
0 / 5 - 0 ratings