The command in the condintion of the loop structure, like while or until, is actually executed.
Although it is the way used in C programming from the beginning of learning, I have not understood it is the same in bash shell scripts.
So, look the sample script below;
#!/bin/bash
### Variable
count=0
### Main
while echo $count; do
if [ “$count” = “10” ]; then
echo “Terminates loop.”
break
fi
count=$((count + 1))
done
Although while is followed by echo command here, it is not just a check whether the command execution will be successful or not. The command is really executed.
So let’s look the output of executing this script below;
~/bin$ 200823_script_exectution_in_test
0
1
2
3
4
5
6
7
8
9
10
Terminates loop.
0
1
2
3
4
5
6
7
8
9
10
Terminates loop.
As you look, outputs by echo $count line vertically.