while question
Kurt Wall
kwall at kurtwerks.com
Tue Nov 18 22:56:12 PST 2008
On Tue, Nov 18, 2008 at 07:50:21AM -0800, idan72 wrote:
>
> Hi,
>
> I try to run the following code below that contain a while statement.
> As you can see in the output it read each line in the file and echo it.
> My question is why when I exit the while loop the value of the vars yyy and
> f is undefined.
>
> Thanks
>
> cat junk.txt | while read yyy; do echo $yyy ;export f=1 ; done ; echo
> l-$yyy; echo f=$f ;
> 444
> 555
> 333
> l-
> f=
> [ishai at mip-devtest ishai]$ cat junk.txt
> 444
> 555
> 333
The script executes in a sub-shell. Values set in a sub-shell are not
exported to the parent.
Kurt
--
You would if you could but you can't so you won't.
More information about the Linux-users
mailing list