Bash – Write A Sequential For Loop

Examples

bashterm

A sequential for loop in bash script is accomplished in the following example:

for i in {1..100}
do
    # Do something here
    echo "${i}"
done

This example iterates from 1 to 100 (inclusive) and prints the index number.

Note: This only works in modern versions of bash (3.x+).

No Comments

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>