Hi guys I am currently trying to implement zenity progress bar to my while loop, however I noticed that my variable which are meant to be incremented did not increment. Here is a sample test script I tried:
i=0
p=0
while [ $i -lt 10 ]
do
i=$[$i + 1]
echo $i
p=$[$p + 1]
done | (zenity --progress --title="test" --text="test")
echo "i: $i p: $p"
I noticed that the progress bar worked, however the variable p
which is meant to be a counter was affected by zenity. Is there something wrong with my code? variable i
is meant to echo the value in order to move the progress bar, while variable p
is meant for other purposes. The values of p
and i
are both 0
despite incrementing it within the while loop.
I am hoping that there is a way to make the variable p
and i
increment without removing the zenity progress bar. I am not sure why however, the incrementing of the variables work after the line (zenity --progress --title="test" --text="test")
is removed
Addition
How to use the variables i
and p
after the progress bar ended? And one more question, is it required to enclose the while loop with ()
?
Thanks for any help!