Source

Wiki Pages / Bash

Full commit
**Bash** is a [[Unix]] shell.

== For Loop Examples

{{{#!bash
$ for i in 1 2 3 4
> do
>     echo $i
> done
1
2
3
4
}}}

{{{#!bash
$ for i in $(seq 0 2 10)
> do
>     echo $i
> done
0
2
4
6
8
10
}}}

{{{#!bash
$ for (( c=1; c<=5; c++ ))
> do
>     echo $c
> done
1
2
3
4
5
}}}

{{{#!bash
$ for (( ; ; ))
> do
>    echo "Infinite"
> done
Infinite
Infinite
Infinite
# Press ctrl-c
}}}

{{{#!bash
$ for i in $(seq 1 100)
> do
>     if [ $i == 50 ]
>     then
>         echo "Loop broken at $i"
>     fi
> done
Loop broken at 50
}}}