i have a CSV file with 3 columns. It looks like this
col1,col2,col3
123,abc , 2015-01-01
246,def , 2015-02-02
How can i remove the white space in col3 only using vim/sed?
expected output:
col1,col2,col3
123,abc ,2015-01-01
246,def ,2015-02-02
i have a CSV file with 3 columns. It looks like this
col1,col2,col3
123,abc , 2015-01-01
246,def , 2015-02-02
How can i remove the white space in col3 only using vim/sed?
expected output:
col1,col2,col3
123,abc ,2015-01-01
246,def ,2015-02-02
$ cat foobar.csv
col1,col2,col3
123,abc , 2015-01-01
246,def , 2015-02-02
$ sed 's/\(.*\),\(.*\),\(\s*\)\(.*\)/\1,\2,\4/' foobar.csv
col1,col2,col3
123,abc ,2015-01-01
246,def ,2015-02-02
Remember the -i
flag if you want to edit the file in place.