I would like to remove multiple spaces in a file with a single character. Example
cat kill rat
dog kill cat
I used the following regex, which seemed to matched in http://www.regexpal.com/ but wasn't working in sed.
([^ ])*([ ])*
I used the sed command like so:
sed s/\(\[\^\ \]\)*\(\[\ \]\)*/\$1\|/g < inputfile
I expect,
cat|kill|rat
dog|kill|cat
But I couldn't get it to work. Any help would be much appreciated. Thanks.
Edit: kindly note that cat/dog could be any character than whitespace.