help with search and replace in multiple fields

I have a pipe delimited file with 27 fields. Each record has 26 fields. I need to search for the 25,26,27 fields and replace "," with nothing.

How can I acheive this. Sed is more preferred.

e.g

data row

o/p

awk -F"|" -vOFS="|" '{sub(",","",$25);sub(",","",$26);sub(",","",$27);print}' file

Hi.

Not sure that sed is the best for that.

$ awk 'BEGIN { OFS=FS="|" } 'function GSUB( F ) { gsub( ",", "", $F ) } { GSUB( 25 ); GSUB( 26 ); GSUB( 27 ) } 1' file

19|147444|3006266|Sponsorships 001|1869440|070210||Colorado Springs |300x100|B4098575.31|100|Scion|Da|Da|1,491|0|0.0|Clicks|2010-07-03|0|1,491|0|0|Y|1566|0|732011

scottn,

I am getting below error with your command

---------- Post updated at 01:42 PM ---------- Previous update was at 01:40 PM ----------

got it. figured out

Ooh! Me too :smiley:

Don't know what happened there... back to the original:

$ awk -F\| -v OFS=\| 'function GSUB( F ) { gsub( ",", "", $F ) } { GSUB( 25 ); GSUB( 26 ); GSUB( 27 ) } 1' file1       
19|147444|3006266|Sponsorships 001|1869440|070210||Colorado Springs |300x100|B4098575.31|100|Scion|Da|Da|1,491|0|0.0|Clicks|2010-07-03|0|1,491|0|0|Y|1566|0|732011

Thanks Scottn and bartus