I have a couple variables a , b and c.
On a for loop I wanted to display all their values.
for i in ${!a[@]}; do
echo "${a[$i]} ${b[$i]} ${c[$i]}"
done
Now values are shifted to the top since other values in variable c are intentionally empty.
mammals land elephant
reptile water pigeon
birds air
How do I create an empty variable so that the values won't get shifted?
I tried doing if the string matches "water" then it will echo only a and b.
for i in ${!a[@]}; do
if [ "$c" = "water"]; then
echo "${a[$i]} ${b[$i]}"
else
echo "${a[$i]} ${b[$i]} ${c[$i]}"
fi
done
EMPTYas an array, even though it's not. You also use the arraycas a non-array in the test. Are these typos in the question only?