小编use*_*083的帖子

检查文件是否存在,然后继续在Bash中退出

我有一个脚本,它是发送电子邮件的其他链中的一个脚本.

在脚本开始时,我想检查文件是否存在,只有在存在时才继续,否则只是退出.

这是我的脚本的开始:

if [ ! -f /scripts/alert ];
then
    echo "File not found!" && exit 0
else
        continue
fi
Run Code Online (Sandbox Code Playgroud)

但是我不断收到一条消息说:

line 10: continue: only meaningful in a `for', `while', or `until' loop
Run Code Online (Sandbox Code Playgroud)

有什么指针吗?

bash if-statement continue

18
推荐指数
1
解决办法
8万
查看次数

标签 统计

bash ×1

continue ×1

if-statement ×1