write a bash shell script that counts down from 10 to 1 and then echoes using a while loop. code example
Example: shell script:while done
while [ condition ]
do
command1
command2
command3
done
while [ condition ]; do commands; done
while control-command; do COMMANDS; done
x=1
while [ $x -le 5 ]
do
echo "Welcome $x times"
x=$(( $x + 1 ))
done
x=1; while [ $x -le 5 ]; do echo "Welcome $x times" $(( x++ )); done
counter=$1
factorial=1
while [ $counter -gt 0 ]
do
factorial=$(( $factorial * $counter ))
counter=$(( $counter - 1 ))
done
echo $factorial
$ chmod +x script.sh
$ ./script.sh 5