Hi,
I have a requirement as below
Input
Jacuzzi,"Jet Rings, Pillows",Accessory,Optional,,9230917,69094,,P556805,69094,FALSE,1,0,,
Jacuzzi,"Jet Rings, Pillows, Skirt/Apron",Accessory,Optional,,9230917,69094,,P556805,69094,FALSE,1,0,,
Output
Jacuzzi,"Jet Rings!@% Pillows",Accessory,Optional,,9230917,69094,,P556805,69094,FALSE,1,0,,
jacuzzi,"Jet Rings!@% Pillows!@% Skirt/Apron",Accessory,Optional,,9230917,69094,,P556805,69094,FALSE,1,0,,
i.e. commas present within the column which has double quotes has to be replaced by the !@%.
To achieve this I have used sed.
sed -e 's/\("[^"][^,]*\),\([^"]*\),\(
[^"]*[^,]"\)/\1!@%\2!@%\3/g' -e 's/\("[^"][^,]*\),\([^"]*[^,]"\)/\1!@%\2/g' "$file"
But now the requirement has changed. Previously I was expecting only 1 or 2 commas i.e. a pattern like "abc,gbf" or "abc,kil,jik" can only come but now I have to generalize it for any no of commas i.e 1,2,3 ---
Any ideas about how to achieve the above.
Thanks for your help in advance.