シェルスクリプトで指定回数ループ処理


シェルスクリプトで指定回数ループ処理するにはどういった書き方があるでしょうか




### for / `seq # #`:

[code]

    for i in `seq 0 9`
    do
      echo "i = $i";
    done
    
[/code]

### for / C-style ( POSIX 標準外):

[code]

    declare -i i
    for (( i = 0 ; i < 10 ; i++ ))
    do
      echo "i = $i";
    done
    
[/code]

[code]

    for (( i = 0 ; i < 10 ; i++ )) {
      echo "i = $i";
    }
    
[/code]

### for / {#..#} ( _>= bash-3.0_ ):

[code]

    for i in {0..9}
    do
      echo "i = $i";
    done
    
[/code]

### while / -lt ~ $(())

[code]

    declare -i i=0
    while [[ $i -lt 10 ]]
    do
      echo "i = $i"
      i=$((i+1))
    done
    
[/code]

* * *

_Output_ :

[code]

    i = 0
    i = 1
    i = 2
    i = 3
    i = 4
    i = 5
    i = 6
    i = 7
    i = 8
    i = 9
    
[/code]

  * Bash Reference Manual, [Looping-Constructs](http://www.gnu.org/software/bash/manual/bashref.html#Looping-Constructs)




### for / `seq # #`:

[code]

    for i in `seq 0 9`
    do
      echo "i = $i";
    done
    
[/code]

### for / C-style ( POSIX 標準外):

[code]

    declare -i i
    for (( i = 0 ; i < 10 ; i++ ))
    do
      echo "i = $i";
    done
    
[/code]

[code]

    for (( i = 0 ; i < 10 ; i++ )) {
      echo "i = $i";
    }
    
[/code]

### for / {#..#} ( _>= bash-3.0_ ):

[code]

    for i in {0..9}
    do
      echo "i = $i";
    done
    
[/code]

### while / -lt ~ $(())

[code]

    declare -i i=0
    while [[ $i -lt 10 ]]
    do
      echo "i = $i"
      i=$((i+1))
    done
    
[/code]

* * *

_Output_ :

[code]

    i = 0
    i = 1
    i = 2
    i = 3
    i = 4
    i = 5
    i = 6
    i = 7
    i = 8
    i = 9
    
[/code]

  * Bash Reference Manual, [Looping-Constructs](http://www.gnu.org/software/bash/manual/bashref.html#Looping-Constructs)

