|
|
|
|
|
by nburger
4072 days ago
|
|
Here's a solution using just one instance of jq+awk that handles the "multiple files" scenario and writes proper headers on each: jq -r '.[]|[.timestamp,.name,.creditcard]|@csv'<data.json|awk -F, '{if ($3!=""){f=substr($1,2,10)".csv";gsub(/-/,"",f);gsub(/"/,"",$0);c="(echo name,creditcard;cat -)>>"f;print $2","$3|c}}' Strangely, the OP's "solution" actually omits the quotes around the strings, which adds unnecessary complexity. |
|