shell 判断条件,退出程序

$cat exit.sh

testvcf=$1

if [ ! -f $testvcf ];then
echo "testvcf nonexist :$testvcf"
exit 0
fi
echo "run successful"

$ cat  run_Exit.sh  

 sh exit.sh 3err
sh exit.sh 2err
sh exit.sh 4err

  

结果

 

 

有的shell 在运行时候发现文件丢失,想先把存在的文件跑了,就适用

  先判断哪些文件在,在接着运行,还不会报错,影响其他任务

posted on 2022-03-17 14:46  BioinformaticsMaster  阅读(716)  评论(0编辑  收藏  举报

导航