I'm having an issue with a bit of code -
while read my_var
let "COUNTER += 1"
if [ $var = "0" ]
printf "Other stuff"
if [ $COUNTER = "30" ]
read -s -p "Press Enter To Continue - "
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 -
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?