sed command to collapse whitespace
by __John_L. from LinuxQuestions.org on (#5EES0)
I'm trying to write a sed command to collapse white space (tab, newlines, spaces, etc.) and whittle consecutive characters down to one space.
I tried:
Code:sed "s/\s+/ /gm" infile.txt >outfile.txtand also:
Code:sed "s/\s{1,}/ /gm" infile.txt >outfile.txtbut both have no effect on whitespace in the input. So much for walking with sed.
Thanks in advance for any help you can provide.


I tried:
Code:sed "s/\s+/ /gm" infile.txt >outfile.txtand also:
Code:sed "s/\s{1,}/ /gm" infile.txt >outfile.txtbut both have no effect on whitespace in the input. So much for walking with sed.
Thanks in advance for any help you can provide.