while read in bash

der.hans plug-devel@lists.PLUG.phoenix.az.us
Mon May 28 21:37:01 2001


Am 26. May, 2001 schwäzte Rusty Carruth so:

> Here's how I'd probably do it (I won't say do it in perl - even though
> I've started to become much more of a 'do it in perl' person ;-)

Not a bad thing, but not what I'm needing for what I'm trying to do :).

> the following lines replace the 'grep root ...' and the 'do' lines -
> not really pretty, but it SHOULD work...)  (its tired, and I'm late ;-)

Actually, this was just a test script to figure out how to get the "while
read" to work. The actual script did something else entirely. Sorry for not
making that clear.

I've fixed it by just taking a line at a time and pulling out the items I
need. I could probably do it better with awk, but what I have is functional.
However, it still doesn't explain why read causes while loops to end up with
local instances of the variables that lose scope upon exiting the while
loop.

That's really what I'm trying to learn.

danke,

der.hans
-- 
# der.hans@LuftHans.com home.pages.de/~lufthans/ www.DevelopOnline.com
#  A t-shirt a day keeps the noose (tie) away. - der.hans