Monday 24 October 2016

script to print zero to ten number

#!/bin/bash
num=0
while [ "$num" -lt 10 ];
do
echo "$num"
num=$((num+1))
done

In the above script we have first assigned zero value to variable num.
Then we are using while loop to iterate until the condition specified is valid,
That is it will continue to the operation till the num value is less than Ten.
do will perform the task specified.
echo will print the current value of num.


Output
0
1
2
3
4
5
6
7
8
9

No comments:

Post a Comment