问题描述:

I am looking to parse the json file using JQ utility in bash script , though i am able to parse it correctly , whenever there's invalid json content we get parse error message on the cmd line . So Question is how do we suppress that parse error message from the screen .

Why do i want to suppress the parse error messsage ?

I am running through loop for evaluating certain conditions in json file , for which i need to parse it first using jq. So whenever the script runs and it encounters invalid json which it is not able to parse we get series of parse error message on the screen , which is something i want to suppress .

网友答案:

If you do want simply to redirect the error message, then consider handling the error programmatically within jq, e.g.

$ jq -n 'try inputs catch "The end"' <<< 'silly'
"The end"

(Note the use of the -n option.)

相关阅读:
Top