我正在使用read命令捕获文件/文件夹名称并进一步检查它们是否存在,但是下面的脚本仅适用于单个文件/文件夹,并且无法捕获多个文件/文件夹。请帮忙! 谢谢!
echo -n "Please enter a name of file/folder you wish to backup: "
read FILE
while [ ! -e "$FILE" ] ;do
read -p "The file ["$FILE"] does not exist."
echo -n "Please enter a name of file/folder you wish to backup: "
read FILE
done
答案 0 :(得分:0)
我建议采取类似的方法:
您可以使用CTRL + C强制退出。
请注意,这应该是一个
if
声明 确保正确的逻辑流,因为&&
||
不等于if
then
else
逻辑
if [ "foo" = "foo" ]; then
echo expression evaluated as true
else
echo expression evaluated as false
fi