BASH question
Lennart Sorensen
lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Fri Dec 21 17:23:12 UTC 2007
On Fri, Dec 21, 2007 at 12:15:24PM -0500, Dave Mason wrote:
> I wasn't aware of this new-fangled syntax:
>
> while ...; do
> ...
> done < <(ls -l)
>
> but it does appear to work. If you want something that works with older
> shells, you can do something like:
>
> ls -l | (
> while ...; do
> x=...
> done
> ... $x ...
> )
>
> where everything in the () runs in a separate shell with stdin set to
> the pipe.
Of course since that one is a subshell, any variable you set in that
loop, won't be available to the main script.
Can't you just do:
ls -l | while ...; do
x=...
done
... $x ...
Does it need a subshell?
--
Len Sorensen
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list