How to print 1-10 numbers using shell script?
How to print 1-10 numbers using shell script?
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Aviance School is one of the largest web solutions platform in India for developers to learn and share their programming knowledge and build their careers.
#!/bin/bash
# using for loop
for (( i=1; i<=10; i++ ))
do
echo -n "$i "
done
# using while loop
j=1
while [ $j -le 10 ]
do
echo -n "$j "
j=$(( j + 1 ))
done
Output:
1 2 3 4 5 6 7 8 9 10