I have a problem with for loop in bash. For example:
I have an array ("etc" "bin" "var")
.
And I iterate on this array. But in the loop I would like append some value to the array. E.g.
array=("etc" "bin" "var")
for i in "${array[@]}"
do
echo $i
done
This displays etc
bin
var
(of course on separate lines).
And if I append after do
like that:
array=("etc" "bin" "var")
for i in "${array[@]}"
do
array+=("sbin")
echo $i
done
I want: etc
bin
var
sbin
(of course on separate lines).
This is not working. How can I do it?