1

The exact question was asked here:

Using jq within pipe chain produces no output

but the answser provided there did not solve my problem. Also, I read the following:

None of these solved my problem. OK, the above info is to let you know that I have done my homework, and please do not downvote or close this question, before you read on :-)

I use the following command to pretty print a json file:

cat a-json-file.json |jq|less

But the screen shows an (END) at the bottom, nothing is displayed. I then googled the problem, found the above info, tried:

cat a-json-file.json |jq --unbuffered|less

nothing happens. Then I installed expect, try:

cat a-json-file.json |unbuffer jq|less

It does not work either, jq simply output its command line usage info!

Finally, I got the problem solved by this:

jq "." a-json-file.json |less

Now, the question is, WHY pipe chain does not work with jq, and what's the difference between the above non-working and working commands?

My system info: Debian 10 buster, jq-1.5-1-a5b5cbe.

xrfang
  • 215
  • 2
  • 10

1 Answers1

3

The comment by @steeldriver solved the problem:

Did you also try cat a-json-file.json |jq '.'|less? This seems to have been a known issue with jq 1.5 - see for example Redirecting or piping output has different behaviour #1028 and the Bug fixes section of the jq 1.6 release notes

Kusalananda
  • 333,661
xrfang
  • 215
  • 2
  • 10