[ale] sed question

David S. Jackson deepbsd at earthlink.net
Thu Nov 7 09:30:29 EST 2002


On Wed, Nov 06, 2002 at 10:39:05PM -0500 Chuck Huber <chuck at cehuber.org> wrote:
> On Wed, Nov 06, 2002 at 07:52:06PM -0500, David S. Jackson wrote:
> > How would I solve the following problem:
> > 
> > ]$ for i in `cat sample.txt|sed -e 's/ /\ /g'; do
> > > echo $i
> > > done
> > 
> > where sample.txt is a simple text files with words and sentences
> > and spaces between the words. 
> 
> It would seem that the sed merely substitutes a space for a space.

Yeah, I was forgetting that "for" was interpreting the spaces as
delimiters, just like it's supposed to be doing.  I was thinking
it was the shell that was interpreting the spaces and that
escaping them would fake it out, but it was "for" all along.  I
should have just used a "while read var" statement.  Doh.  :-)


-- 
David S. Jackson                        dsj at dsj.net
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
I am a conscientious man, when I throw rocks at
seabirds I leave no tern unstoned.
	-- Ogden Nash, "Everybody's Mind to Me a Kingdom Is"

 PGP signature




More information about the Ale mailing list