Home > database >  How can I use gsub to remove single quot and comma from a column
How can I use gsub to remove single quot and comma from a column

Time:09-17

I have an awk 'print{$15,$25,$29}' output in below format which I need to remove the special character symbol(',) using gsub. Can anyone help me with a format to use to get the desire output.

current output

'abc' 'def', 'ghi'

expected output

abc def ghi

CodePudding user response:

Either of these work:

awk '{gsub(/['\'',]/, ""); print $15,$25,$29}' Input_file
awk '{gsub(/[\047,]/, ""); print $15,$25,$29}' Input_file

The first uses '\'' to escape a single quote. The second uses octal notations for the single quote.

The [] creates a class including the single quote and commas, which are both replaced with "".

  • Related