Introduces jpeg-recovery source-code
[lcapit-junk-code.git] / array.sh
blob4982e86e4464e15e9d8f531d083f0355a82c542b
1 #!/bin/bash
3 # Arrays in bash.
5 # Luiz Fernando N. Capitulino
6 # <lcapitulino@gmail.com>
8 ###
9 ### First way
10 ###
11 ### name=(value1 value2 valueN)
13 array1=(a b c d e f g h)
15 for ((i = 0; i < 8; i++)); do
16 echo ${array1[i]}
17 done
19 echo
21 ###
22 ### Second way
23 ###
24 ### name[subscript]=value
26 for ((i = 0; i < 5; i++)); do
27 array2[i]=$i
28 done
30 for ((i = 0; i < 5; i++)); do
31 echo ${array2[i]}
32 done