0

I am parsing the csv file using while loop in shell script which has data in below format

ba04ba54,1234,MMS,"[""some"", ""somet2"", ""somet""]",21556,48834

code:

while IFS=, read -r id mvid conkey values cretime modified; 
do
echo $id,$mvid,$conkey,$values,$cretime,$modified

but values is assigned with

"[""some""

instead of

"[""some"", ""somet2"", ""somet""]" how to achieve this using shell script
Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182

1 Answers1

0

Could you please try following.

awk 'match($0,/\"\[\".*\]\"/){print substr($0,RSTART,RLENGTH)}' Input_file
RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
  • It works fine but it is not working for othe json format like "[{""abc"":[{""ABC"":""[0].ABCD.[0].value"",""XYZ"":""-ID"",""value"":""test""}}]] can you please explain it – iiiiiiiiiiiii Jan 11 '19 at 10:25
  • @jayashri, awk is not made for json parsing, please use json parser for same. – RavinderSingh13 Jan 11 '19 at 11:17