While statement
This statement is another iteration statement which is offered through the shell programming language. While statement causes a block of code to be executed although a provided conditional expression is true.
Syntax
while [ command-list1 ]
do
done
command-list2
The value tested through the while command is the exit status of the final simple command following while. After the each iteration command-list1 is executed; if a zero exit status is returned then command-list2 is executed; else, the loop terminates. For instance,
while test $1
do ...
shift
done
is equivalent to for i
do ...
done
shift is a shell command which renames the positional parameters $2, $3, ... as $1, $2, ... and loses the parameter $1. In the given example the shift command moves the command-line parameters to the left through one parameter.