dear community, I faced the problem that I can't break the while loop in this example. This script should output how many files are in the folder and when this count will be 0 do another step. But, when I'm executing the script and after deleting file/files from the folder the loop fails to meet the condition and continue working. Mb I'm doing something wrong because I'm the newest in the bash scripting. Will be appreciate your advice
var=$(ls some_folder/ | wc -l )
echo "$var"
while [ $var != 0 ];
do
sleep 2
echo "$test"
done
echo "finish!"
var
once, before the loop starts. It never changes inside the loop. You need to assign a new value for it inside the loop.