Shell scripting: loop through an array or positional access








# declare a empty array
declare -a array1=()

array1+=('foo')
array1+=('bar')

echo ${array1[0]} # foo
echo ${array1[1]} # bar

for elem in "${array1[@]}"
do
    echo $elem
done



No comments:

Post a Comment