RE: How to print 1-10 numbers using shell script?

How to print 1-10 numbers using shell script?

chayan Senior Developer Asked on December 7, 2017 in LINUX.
Add Comment
1 Answers

 

#!/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

 

Team Leader Answered on December 27, 2017.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.