[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: something unclear with sed for me



On Wed, May 11, 2005 at 03:01:47PM +0300, Andras Lorincz wrote:
> I want to replaces all multiple spaces with one space. My first
> attempt was this:
> 
> sed -e 's/\ */\ /g'

The asterisk means zero or more, so it matches evven if there are 
no spaces.

> 
> 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?
> 

-- 
David Jardine

"Running Debian GNU/Linux and
loving every minute of it."  -L. von Sacher-M.(1835-1895)



Reply to: