I need to replace all white spaces inside my text with commas. I'm currently using this line but it doesn't work: I get as output a text file which is exactly the same of the original one:
sed 's/[:blank:]+/,/g' orig.txt > modified.txt
thanks
regular expressionsedtext processing
I need to replace all white spaces inside my text with commas. I'm currently using this line but it doesn't work: I get as output a text file which is exactly the same of the original one:
sed 's/[:blank:]+/,/g' orig.txt > modified.txt
thanks
Best Answer
With GNU
sed
:Or with
perl
:Edit: To exclude newlines in Perl you could use a double negative
's/[^\S\n]+/,/g'
or match against just the white space characters of your choice's/[ \t\r\f]+/,/g'
.