Table of Contents

bash

in

$ for i in 1 2 3; do echo $i; done 1
2 3

seq

$ for i in `seq 1 10`; do echo $i; done 1
2 ... 10 $ for i in `seq 1 3 10`; do echo $i; done 1
4 7
10

a la C

$ for ((i=1;p<=5;i++)); do echo $i; done 1
2 3
4 5
$ for ((p=1,q=2;p<=10;q<20;p+=2;q=q+3)); do ...; done

while

$ i=1; while [ $p -le 5 ]; do echo $i; i=$[i+1]; done 1
2 3
4 5

DOS/Windows

C:\> for %i in ( 1 2 3 ) do echo %i 1
2 3
C:\> for %f in ( *.txt ) do notepad %f satu.txt dua.txt tiga.txt