Page is a not externally linkable
- Hardware and OS Related Technologies
-- Linux, Unix, and *nix like Operating Systems
---- SED replace double spaces


phranque - 8:28 am on Sep 17, 2010 (gmt 0)


those first two examples won't work because sed doesn't support BRE.

combining all of the above, try this:
perl -p -i.bak -e 's/\s\s+/,/g;' filename.txt

this will create a backup and then loop through filename.txt, replacing two or more consecutive whitespace characters with a single comma.
i'm guessing \s\s+ is a more efficient regexp than \s{2,} but they both work.


Thread source:: http://www.webmasterworld.com/linux/4200711.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com