While Condition
While tests for a
condition at the top of a loop, and keeps looping as long as that condition is true. while loop is useful where the number
of loop repetitions is not known.
Syntax of while loop
while
condition
do
statements
done
while [ condition ] ;
do
statements
done
Example:
While loop script for printing digit 1 to 10
#!/bin/bash
max=10
a=1
while
[ "$a" -le $max ]
do
echo
-n "$a "
let
"a+=1"
done
echo
exit 0
|
No comments:
Post a Comment