> From: Andras Lorincz [mailto:[EMAIL PROTECTED] > > I want to replaces all multiple spaces with one space. My > first attempt was this: > > sed -e 's/\ */\ /g' > > This replaced all multiple spaces with one but as a side > effect, sed inserted a space between all characters. Playing > a little I tried > this: > > sed -e 's/[\ ]\ */\ /g' > > and this works. The fact is that I don't understand why the > first one doesn't work. Can someone explain me that? >
You can use + that means one or more of the preceding character. But + is defined in extended regular expression. use -r option for the extended regular expression like this: sed -r 's/ +/ /g' -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]