Awk to Search and Replace inside the pipe "|"

Hi,

Anyone can help me on how to replace the qoutes
inside the pipe | in my Text File like belows;

"AAAA"|"Test "1-A""|"Test AAAA"|"This is A"
"BBBB"|"Test "1-B""|"Test BBBB"|"This is B"
"CCCC"|"My Test C"|"Test "CCCC""|"This is C"

The output I need like belows;

"AAAA"|"Test 1-A"|"Test AAAA"|"This is A"
"BBBB"|"Test 1-B"|"Test BBBB"|"This is B"
"CCCC"|"My Test C"|"Test CCCC"|"This is C"

Thanks in Advance,
FSPalero

AWK

awk 'gsub("\"\"","\"")' infile

SED

sed 's/""/"/g' infile
 $ ruby -i -ne 'print $_.gsub!(/""/,"\"")' file 
sed -i 's/""/"/g' /path/to/file

---------- Post updated at 02:40 AM ---------- Previous update was at 02:39 AM ----------

lol damn...too slow

it the same, giving an output;

$ awk 'gsub("\"\"","\"")' awk-test.txt
  "AAAA"|"Test "1-A"|"Test AAAA"|"This is A"
  "BBBB"|"Test "1-B"|"Test BBBB"|"This is B"
  "CCCC"|"My Test C"|"Test "CCCC"|"This is C"
$ sed 's/""/"/g' awk-test.txt
  "AAAA"|"Test "1-A"|"Test AAAA"|"This is A"
  "BBBB"|"Test "1-B"|"Test BBBB"|"This is B"
  "CCCC"|"My Test C"|"Test "CCCC"|"This is C"

@fspalero @pravin27 @kurumi @DC Slick:

You missed the " which is before the CCCC

sed 's/"//g;s:|:"|":g;s:.*:"&":' infile

hi ctsgnb, It worked like a charm. Thank you.

awk -F\| -v s="\"" '{gsub(s,""); for (i=1;i<=NF;i++) $i=s $i s}1' OFS=\| infile

hi ctsgnb,

can you help me please to include on how to replace the 4th line, it was |"My Test D|1"| would be come |"My Test D1"|.

My Data :

"AAAA"|"Test "1-A""|"Test AAAA"|"This is A"
"BBBB"|"Test "1-B""|"Test BBBB"|"This is B"
"CCCC"|"My Test C"|"Test "CCCC""|"This is C"
"DDDD"|"My Test D|1"|"Test "DDDD"|"This is D"

Output :

"AAAA"|"Test 1-A"|"Test AAAA"|"This is A"
"BBBB"|"Test 1-B"|"Test BBBB"|"This is B"
"CCCC"|"My Test C"|"Test CCCC"|"This is C"
"DDDD"|"My Test D 1"|"Test "DDDD"|"This is D"

Thanks and in Advance,
FSPalero

awk '{for(i=1;i<=NF;i++){gsub(/\|/," ",$i);gsub(/"/,x,$i)}$1="\""$1;$NF=$NF "\""}1' FS='"\\|"' OFS='"|"' infile

Hi Scrutinizer,

Excellent, it works well. Thanks in a millions.

Regards,
FSPalero

sed 's:|\([^"]\): \1:g;s:\([^"]\)|:\1 :g' infile

Hi Ctsgnb,

Great! it work well, many many thanks for the helps you guys. You save me a lot.

Regards,
FSPalero