Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

removing specific character from specific column in unix file

I have unix file with csv format like below

   col1,  col2,  col3,  col4
   abc,   efg,   h,i,j  lmn

Need to remove "," from col3 and keep , separated values. Any help ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Instead of using I suggest using for this. Since the columns are separated by one or more whitespaces, you can use the global substitution function gsub on the third column.

This replaces , (the regex /,/) with an empty string ("") in the third column ($3):

awk '{gsub(/,/,"",$3)}1' the_file
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading