Looping with Numbers

Problem Statement

for loops in Bash can be used in several ways: – iterating between two integers, a and b – iterating between two integers, a and b, and incrementing by c each time – iterating through the elements of an array, etc.

Use _for: loops to display the natural numbers from 1 to 50.

Input
There is no input

Output

1
2
3
4
5
.
.
.
.
.
50  

Recommended Resources

A quick but useful tutorial for Bash newcomers is here.
Handling input is documented and explained quite well on this page.
Different ways in which for loops may be used are explained with examples here.

Solution

  
for x in {1..50}
do
    echo $x
done

Leave a Reply