How to Write Bash FOR-Loops

In this tutorial we will show you how to write a Bash FOR-Loop script. A loop is basically something that repeats itself unless told to stop. Over here the Bash FOR-Loop command allows you to repeat words or numbers in a given string. In the tutorial below, the string consists of the numbers from one till ten which skip internally inside the string from a difference of three.
To understand how the bash for-loops script works look at the steps given below.


Step 1 – Enter command

For loops in bash first of all, we will enter the “for” keyword followed by the count variable. Over here, we will specify the count starting from one and ending up till ten, with an increment of 3.
for count in {1..10..3}

Insert command

Step 2 – Enter the “do” keyword

After that, we will start the bash for-loops with the “do” keyword and print the results using the echo command.
do
echo “$count”
done

Insert the “do” keyword

Step 3 – View the displayed output

Once the script has started, you can see that the output is displayed according to the specified condition, that the count has started from one and each value is incremented by 3.
And that’s it, the above steps need to be carried out for loops in bash to be created.

Look at the displayed output