for loop 使用例

文字変数の配列

$ for str in Aa Bb Zzz; do echo "string $str"; done
string Aa
string Bb
string Zzz

前ゼロ連番

$ for i in {01..03}; do echo "count $i"; sleep `expr $RANDOM % 5`; done
count 01
count 02
count 03

50おきにカウントして、先頭と末尾を出力。

$ for i in {0..20150..50}; do echo "count $i"; done | (head;tail)
count 0
count 50
count 100
count 150
count 200
count 250
count 300
count 350
count 400
count 450
count 19700
count 19750
count 19800
count 19850
count 19900
count 19950
count 20000
count 20050
count 20100
count 20150