I have files with 1 json document per row and the fields start_id
and end_id
in each document. I'd like to use jq to extract these and print them on the same row.
So far I have:
cat part* | jq '"\(.start_id) \(.end_id)"' | sed s/\"//g | head
This works, but I need the sed
to remove the double quotes.
In order to improve my jq-foo, is there a way to do this without using sed?
e.g. given
{"start_id":1,"end_id":50}
{"start_id":50,"end_id":99}
{"start_id":99,"end_id":12}
get
1 50
50 99
99 12
instead of
"1 50"
"50 99"
"99 12"
By default, jq
formats its output to be a valid JSON value. This means that character strings are wrapped in quotes.
Fortunately, the --raw-output
or -r
parameter overrides that behaviour so your string output can be free of those nasty quotation marks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With