I want to trim only the leading whitespaces from a csv file that looks something like this:
thing1,thing2, thing something3,thing4
thing11,thing12, thing something13,thing14
etc.
(note: I want to keep the space between thing and something3)
so my output would be like this:
thing1,thing2,thing something3,thing4
thing11,thing12,thing something13,thing14
I’ve tried using awk '{$1=$1};1' file and a dozen other solutions that I found with a quick google search, but those usually either freeze or just do nothing in my case.
Hope someone can help me out, cheers!
>Solution :
sed 's/,[[:blank:]]*/,/g' file
Example:
> cat test.txt
thing1,thing2, thing something3,thing4
thing12,thing12, thing something13,thing14
> cat test.txt | sed 's/,[[:blank:]]*/,/g'
thing1,thing2,thing something3,thing4
thing12,thing12,thing something13,thing14