by Sai gowtham

For loop in Bash script

for loop is used to iterate over a list of items until a particular condition is true.

The following example will show you how to write a for loop in bash script.

for ((i = 0 ; i < 10 ; i++ ));
 do
  echo "$i";
 done

In the above code, the for loop starts from 0 and runs up to i<10 on each iteration we are incrementing the i value by 1.

Top Udemy Courses

JavaScript - The Complete Guide 2020 (Beginner + Advanced)
JavaScript - The Complete Guide 2020 (Beginner + Advanced)
45,614 students enrolled
52 hours of video content
View Course
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
284,472 students enrolled
40 hours of video content
View Course
Vue JS 2 - The Complete Guide (incl. Vue Router & Vuex)
Vue JS 2 - The Complete Guide (incl. Vue Router & Vuex)
130,921 students enrolled
21 hours of video content
View Course