sed.
$ echo "The cow jumped over the moon" | sed -e 's/[ ]\+/ /g'
The cow jumped over the moon
In the square brackets of the character class, you have a space and a tab character. I quoted "+" with "\", which might not be necessary if your regular expression engine accepts "+" to mean "one or more" and not the literal "+".
source
share