Loops in UNIX Shell Scripts - while Statement
The while construct allows iterations through a block of script as long as a certain condition is true.
Syntax:
while condition
do
commands
done
Example:
The example script counts up to10 secs.
#!/bin/sh
i=1
while [ $i -le 10 ];
do
sleep 1
print "$i"
i=` expr $i + 1 `
done
exit 0
Syntax:
while condition
do
commands
done
Example:
The example script counts up to10 secs.
#!/bin/sh
i=1
while [ $i -le 10 ];
do
sleep 1
print "$i"
i=` expr $i + 1 `
done
exit 0
Comments
Post a Comment