J'ai un problème avec la boucle for dans bash. Par exemple: j'ai un tableau ("etc" "bin" "var"). Et j'itère sur ce tableau. Mais dans la boucle, j'aimerais ajouter une valeur au tableau. Par exemple
array=("etc" "bin" "var")
for i in "${array[@]}"
do
echo $i
done
Cela s'affiche etc bin var(bien sûr sur des lignes distinctes). Et si j'ajoute après docomme ça:
array=("etc" "bin" "var")
for i in "${array[@]}"
do
array+=("sbin")
echo $i
done
Je veux: etc bin var sbin(bien sûr sur des lignes distinctes).
Ça ne marche pas. Comment puis-je le faire?