I can't seem to get jq
to behave "normally" in a shell pipeline. For example:
$ curl -s https://api.github.com/users/octocat/repos | jq | cat
results in jq
simply printing out its help text*. The same thing happens if I try to redirect jq
's output to a file:
$ curl -s https://api.github.com/users/octocat/repos | jq > /tmp/stuff.json
Is jq
deliberately bailing out if it determines that it's not being run from a tty? How can I prevent this behavior so that I can use jq
in a pipeline?
* (I realize this example contains a useless use of cat; it's for illustration purposes only)
You need to supply a filter as an argument. To pass the JSON through unmodified other than the pretty printing jq
provides by default, use the identity filter .
:
curl -s https://api.github.com/users/octocat/repos | jq '.' | cat