How To Unix For Loop 1 to 100 Numbers

In Unix/Linux, you can use a for loop to iterate through a range of numbers from 1 to 100. Here’s how to do it:

  1. Open a terminal window.
  2. Type the following command to start the for loop:
for i in {1..100}

This will set up the for loop to iterate through the numbers 1 to 100.

  1. Type the commands that you want to execute inside the loop. For example, to print each number to the screen, you can use the echo command:
for i in {1..100}
do
echo $i
done

This will print the numbers 1 to 100 to the screen, each on its own line.

  1. When you’re finished with the loop, type done to exit the loop:
for i in {1..100}
do
echo $i
done

This will execute the loop and print the numbers 1 to 100 to the screen.

Note that the curly braces in the for loop syntax are used to define the range of numbers to iterate through. You can adjust the range to suit your needs. For example, to iterate through numbers from 10 to 20, you can use the following syntax:

for i in {10..20}
do
echo $i
done

Leave a Comment