mardi 19 septembre 2023

convert multiple lines into single seperated by comma

have a json file with tons of records as follows . I need to extract 4 fields and put them in one line of output as show below

{,
"address": "122.22.33.33",
"ipv6_prefix_bits": "0",
"protocol": "IPV4",
"network": "10.118.121.11/14",
"hostname": "abcd.net",
"state": "active"
.....
},
{,
"address":......
...
...
},

OUTPUT 
"hostname": "abcd.net","protocol": "IPV4","network": "10.118.121.11/14","state": "active"
"hostname":.....
,

I tried JQ however I need to do this in a production server where we dont have JQ and so might have to use AWK or SED .

Aucun commentaire:

Enregistrer un commentaire