Removing spaces from columns of a CSV file in bash

Posted by vikas ramnani on Stack Overflow See other posts from Stack Overflow or by vikas ramnani
Published on 2012-06-27T14:37:22Z Indexed on 2012/06/27 15:16 UTC
Read the original article Hit count: 160

Filed under:

I have a CSV file in which every column contains unnecessary spaces(or tabs) after the actual value. I want to create a new CSV file removing all the spaces using bash.

For example

One line in input CSV file

value1             ;value2              ;value3              ;value4

same line in output csv file should be

value1;value2;value3;value4

I tried using awk to trim each column but it didnt work. Can anyone please help me on this ?

Thanks in advance :)

© Stack Overflow or respective owner

Related posts about bash