Reputation: 5
I want to write a shell script for following scenario. I have a record
"apple""banana""pineapple"
And I would like each string to be in double quote, and comma separated, like this:
"apple","banana","pineapple"
Upvotes: 0
Views: 90
Reputation: 4112
You can try this
sed 's/""/","/g'
user@host:~$ echo '"apple""banana""pineapple"' | sed 's/""/","/g'
"apple","banana","pineapple"
Upvotes: 3
Reputation: 195039
this awk one-liner should work for the given example:
awk -F'""' -v OFS='","' '$1=$1'
Upvotes: 1