我有 json 日志文件,例如
{"type":"1","fname":"AAA","lname":"bbb" }
{"type":"2","state":"gujarat" }
{"type":"3","city":"ahmedabad" }
{"type":"3","city":"rajkot" }
{"type":"1","fname":"ccc","lname":"ddd" }
我运行以下命令
jq -c "select(.type==\"1\")|{fname:.fname}" > type_1.txt
jq -c "select(.type==\"2\")|{city:.city}" > type_3.txt
是否只运行 jq 命令一次并生成 2 个输出文件?
答案1
抱歉,无法避免第二次调用jq
。