【发布时间】:2012-04-15 00:33:54
【问题描述】:
在 (ba)sh 脚本中,如何忽略 file-not-found 错误?
我正在编写一个从标准输入读取(部分)文件名的脚本,使用:
read file; $FILEDIR/$file.sh
我需要提供脚本功能来拒绝不存在的文件名。
例如
$UTILDIR 不包含script.sh
用户类型脚本
脚本尝试访问 $UTILDIR/script.sh 并失败为
./run.sh: line 32: /utiltest/script.sh: No such file or directory
如何让脚本打印错误,但继续执行脚本而不打印“正常”错误?
【问题讨论】:
标签: bash file-not-found