I want to remove the space between two distinct chars separated by space.
For example
In String “hello world doddy”, I want the space between hello & world be removed (but preserve the space between world and doddy, since d d pattern needs to be preserved).
I tried:
$ echo "hello world doddy" | sed 's/\(.\) \([^\1]\)/\1\2/g'
But ended up with
helloworlddoddy
Prep the string by first doubling any space that is between two identical characters. The intervening space shifts from being between two identical characters to between one of the characters and a space, so all spaces can be checked the same way.