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

Re: something unclear with sed for me



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andras Lorincz wrote:
> 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. 

You told sed "replace 0 or more whitespace characters with 1 whitespace
character.

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

This time you told sed  "replace 1 or more whitespace characters with 1
whitespace character.


- --

/phil


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)
Comment: Public Key: http://www.dyermaker.org/gpgkey

iD8DBQFCgkw/Gbd/rBLcaFwRAtUqAKCu8C+iNH53011Lq3NGX680H/P4xwCdGUBZ
e78WXTGi3RGpm3uoGFBv04I=
=ZkNQ
-----END PGP SIGNATURE-----



Reply to: