3

I have json log file like

{"type":"1","fname":"AAA","lname":"bbb" }
{"type":"2","state":"gujarat" }
{"type":"3","city":"ahmedabad" }
{"type":"3","city":"rajkot" }
{"type":"1","fname":"ccc","lname":"ddd" }

I run following command

jq -c "select(.type==\"1\")|{fname:.fname}" > type_1.txt
jq -c "select(.type==\"2\")|{city:.city}" > type_3.txt

Is anyway to run jq command only one time and generate 2 output files?

Archemar
  • 31,554
vimal
  • 101

1 Answers1

2

It's not possible to avoid second invocation of jq, sorry.

sendmoreinfo
  • 2,573