Thank you Paul, Andreas and Kevin.
Both the here document solution and the Process substitution solution both
work well. I haven't had a good look to see the subtle differences between
the two yet.
Thank you again.
--
View this message in context:
http://www.nabble.com/while-read-subco
Andreas Schwab <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] (Paul Jarc) writes:
>> while ...; do var=...; done <> $(generate-input-for-while)
>> EOT
>> use "$var"
>
> This has the disadvantage that generator and consumer no longer run
> concurrently. Process substitution does not have this probl
[EMAIL PROTECTED] (Paul Jarc) writes:
> The redirection applied to "read" in those examples would be applied
> to your while loop instead. For example:
>
> while ...; do var=...; done < $(generate-input-for-while)
> EOT
> use "$var"
This has the disadvantage that generator and consumer no longer
On Fri, 2 Mar 2007 03:04:14 -0800 (PST)
rleeden <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I struggled recently with a 'while read' type of loop in bash, where
> after the loop had finished the variables used inside the loop are
> not visible any more. I soon found the problem as explained in
> sect
Richard van der Leeden <[EMAIL PROTECTED]> wrote:
> The examples in the FAQ do work for the their examples, but I can't figure
> out a clean way to implement it with a while loop when reading in lines from
> the output of a piped command(s).
The redirection applied to "read" in those examples woul
to use $var
much later in the script as I would need the rest of the script kept in the
{ }.
I suppose, after years of using the ksh I'm missing the (in my opinion) the
clearer 'command | while read' solution.
--
View this message in context:
http://www.nabble.com/while-rea
rleeden <[EMAIL PROTECTED]> wrote:
> NOTE: This is just an example, so I don't need alternatives for how I could
> achieve the specifics shown above. I need to find a good solution where I
> can do things with a file (whether it be with sed, awk, tail, head etc.)
> then pipe it into a 'while read'
echo "$i : $IP $HOSTNAME"
done < tmpfile
rm tmpfile
echo
echo "Total : $i"
---------
Any ideas?
--
View this message in context:
http://www.nabble.com/while-read-subcommand-problem-tf3332952.html#a9267658
Sent from the Gnu - Bash mailing list archive at Nabbl