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

Re: something unclear with sed for me



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

I dont know about sed. But you can do this with the tr command.

tr -s ' '   is what you are after. For more details see man tr.

raju
--
Graduate student
MAE, Cornell University



Reply to: