If I iterate in bash over multiple arrays and printing its values then the values of the arrays changes. Why?
#!/bin/bash
a=("02" "20")
b=("02" "20")
n=("02" "20")
p=("02" "20")
for p in ${p[@]}
do
for b in ${b[@]}
do
for a in ${a[@]}
do
for n in ${n[@]}
do
echo $b-$a-$n-$p
done;
done;
done;
done
echo "${a[*]}"
The command echo "${a[*]}" yields 20 20 but should be 02 20
Thanks!
for a in ${a[@]}; do :; done. In the future, please try to debug your problems yourself.