我需要在Shell脚本中提供输入列表并读取它们并迭代并为每个文件夹执行'svn update',如下所示:
echo "Please give the list of folders to be updated:"
read $list
for name in ${list[@]} do
svn update $name
done
如何通过shell脚本实现此功能。
谢谢和问候,
拉加
答案 0 :(得分:1)
如果您尝试将值读入数组,请使用: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
但请记住,您的文件夹名称不应包含空格或换行符。
答案 1 :(得分:0)
#!/bin/bash
echo "Please give the list of folders to be updated:"
read list $*
for name in "${list[@]}"; do
svn update "${name}"
done