I'm having an issue with a bit of code -
Code:
while read my_var
do
let "COUNTER += 1"
if [ $var = "0" ]
then
printf "Stuff"
else
printf "Other stuff"
fi
if [ $COUNTER = "30" ]
then
COUNTER=0
read -s -p "Press Enter To Continue - "
fi
done < my_file.txt
I have a list of items in this file. I want to make sure it stops after reading in so many lines (in this case, 30) and make you press enter to continue. First off, the read line doens't work at all for some reason. Second off, every time it actually meets the condition of the second if statement, the while loop increments twice. Why?
So i'd have -
...28
29
30
32...
If the second if is remarked out, it works normally through the list. Why does the second if make the while operate twice? What should I use instead that would allow me to read in a whole line of a file as well?
Devon