cat 2.txt | ./jq '{(.id): .custom}'
above command outputs
{
"1": {
"results": "Success"
}
}
{
"2": {
"input method": "touch",
"from": "Prescription Center",
}
}
{
"3": {
"entry point": "|All"
}
}
Expected output :
I want to print/save each object in a line.
cat 2.txt | ./jq '{(.id): .custom}'
{ "1": { "results": "Success" } }
{ "2": { "input method": "touch", "from": "Prescription Center" } }
{ "3": { "entry point": "|All" } }
will it be possible in shell script?
Per the jq manual
--compact-output
/-c
:By default, jq pretty-prints JSON output. Using this option will result in more compact output by instead putting each JSON object on a single line.
Therefore the following should work:
cat 2.txt | ./jq -c '{(.id): .custom}'
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