我想要自动执行多个 rsync 命令,如下所示:
- 执行 rsync1
- 在终端中显示 rsync1 的输出
- 如果要继续 rsync2,请确认
- 执行 rsync2
有人可以帮忙吗?
答案1
像这样:
# --progress will show rsync progress in real time
rsync1 --progress source dest
read -p "Proceed? [N/y]: " PROCEED
# default response is "n"
PROCEED=${PROCEED:-"n"}
# convert the response to lower case to make it eiser to test
if [ "${PROCEED,,}" = 'y' ]; then
echo "Proceeding..."
else
echo "Stopping"
# change to exit 0 if you don't want this to be an error condition
exit 1
fi
rsync2 --progress source dest