How do I write a for loop in bash


Question

I'm looking for the basic loop like:

for(int i = 0; i < MAX; i++) {
  doSomething(i);
}

but for bash.

1
86
7/15/2019 6:49:01 PM

Accepted Answer

From this site:

for i in $(seq 1 10);
do
    echo $i
done
95
11/21/2017 4:30:53 PM

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

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon