Bourne Shell: scope of variables in while loop
For some reason, I am not able to access variables that were changed in a
while loop, after the while loop finishes. For example:
i=0
echo "this is a test" | while read line
do
i = `expr $i + 1`
done
echo $i
-------------------------------
The echo statement prints 0 rather than 1. Does anyone know why?
|