I have problems with some arrays in bash.
A=( "127.0.0.1" "localhost" "aaa nnn cvcc" )
B=( "8.8.8.8" "dns" "bbb tttt rrrr")
for n in ${A} ${B} ; do
if ping -c3 ${n[0]};then
echo "${n[1]}"
for share in ${n[2]};do
echo $share
done
fi
done
I'd like to print the second and third element of the array but the for loop stop at the ping. This way it is working.
if ping -c3 ${A[0]};then
echo "${A[1]}"
for share in ${A[2]};do
echo $share
done
fi
I'm sure must be a very silly thing but it is driving me mad... Some ideas? Many thanks in advance