gpt4 book ai didi

linux - 如何在 shell 脚本中给出输入列表?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:53:46 25 4
gpt4 key购买 nike

我需要在 Shell 脚本中提供输入列表并读取它们并迭代并为每个文件夹执行“svn 更新”,如下所示:

    echo "Please give the list of folders to be updated:"
read $list
for name in ${list[@]} do
svn update $name
done

如何通过 shell 脚本实现此功能。

感谢和问候,

拉贾

最佳答案

如果您尝试将值读入数组,请使用:read -a

read -a list -p "Please give the list of folders to be updated: "

for name in "${list[@]}"; do
svn update "$name"
done

否则就这样使用:

read -p "Please give the list of folders to be updated: " list

for name in $list; do
svn update "$name"
done

但请记住,您的文件夹名称不应包含空格或换行符。

关于linux - 如何在 shell 脚本中给出输入列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28563577/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com