loops in bash

I use bash regularly to manipulate data, run repeat tasks. There are many ways to carry out loops.

Example 1

for in in 1 2 3 4 5 6 7 8 9 10
do
echo $i
done

Example 2

for i in `seq 1 10 `
do
echo $i
done

Example 3

for (( i=1; i<11; i++ ))
do
echo $i
done

Example 4

while [ i -lt 11 ]
do
echo $i
i=` $i + 1 `
done

About these ads

One response to “loops in bash

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s