Issue with CUT command

Hi All,

I am facing an issue while cutting fields with comma delimiter. There are many records with Double quotes in between.

My data: aaa,bbb,"ccc, ddd",eee,fff,"ggg ,hhh",iii

When i use cut command with comma delimiter, i am getting wrong data like

field1=aaa 
field2=bbb
field3="ccc
field4= ddd"

But i need data like

field1=aaa 
field2=bbb
field3="ccc, ddd"

Regards,
Krish

How are quotes represented within these double quotes?

Do you need to support new-line characters between the double quotes?

eg:

aaa,bbb,"""Smokin'"" Joe Frazier","Next
line"
Field1=aaa
Field2=bbb
Field3="Smokin'" Joe Frazier
Field4=Next
line

Hi,

I do not need new line characters between double quotes.

There are no quotes inside double quotes.

I need field values between double quotes as it is without getting split.

Delimiter is also comma.

aaa,bbb,"ccc, ddd",eee,fff,"ggg ,hhh",iii

expecting :

field1=aaa 
field2=bbb
field3="ccc, ddd"
field4=eee

Regards,
Krish

Try this sed script:

sed 's/\("[^"]*"\)*,\("[^"]*"\)*/\1\n\2/g' infile

For you test record we get:

aaa
bbb
"ccc, ddd"
eee
fff
"ggg ,hhh"
iii