作者:骏马奔腾09 | 来源:互联网 | 2023-07-02 17:30
Ihaveanarrayofapplications,initializedlikethis:我有一个应用程序数组,初始化如下:depends(cat~Depends.tx
I have an array of applications, initialized like this:
我有一个应用程序数组,初始化如下:
depends=(cat ~/Depends.txt)
When I try to parse the list and copy it to a new array using,
当我尝试解析列表并将其复制到一个新的数组时,
for i in "${depends[@]}"
if [ $i #isn't installed ]; then
newDepends+=("$i")
fi
done
What happens is that only the first element of depends winds up on newDepends.
所发生的是,只有依赖的第一个元素最终依赖于newdepend。
for i in "${newDepends[@]}"
echo $i
done
^^ This would output just one thing. So I'm trying to figure out why my for loop is is only moving the first element. The whole list is originally on depends, so it's not that, but I'm all out of ideas.
^ ^这将只输出一件事。我想弄明白为什么for循环只移动第一个元素。整个列表最初都是依具体情况而定的,所以不是那样的,但是我的想法都没有了。
6 个解决方案