DEV Community

Eduardo Issao Ito
Eduardo Issao Ito

Posted on

3

Bash: loops

Different loop styles in bash:

for i in $( ls )
do
    echo $i
done
for i in $( seq 1 10 )
do
    echo $i
done
for ((i = 0 ; i < max ; i++ ))
do
    echo $i
done
i=0
while [ $i -lt 10 ]
do
    echo $i
    i=$((i+1))
done
i=20
until [ $i -lt 10 ]
do
    echo $i
    i=$((i-1))
done

Top comments (0)

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay