shell 之条件判断

在自动化打包的过程中,对生成的文件或者创建的文件夹是否存在,需要使用到shell的基本控制语句,

if [ expression ];
then
   Statement(s) to be executed if expression is true
fi

例子:比如在自动化打包时,判断编译文件.xcarchive是否存在,可以使用文件比较运算符,

# 删除build包
if [[ -d build]]; then
    rm -rf build -r
fi

学习博客:https://www.yiibai.com/shell/if-fi-statement.html

猜你喜欢

转载自blog.csdn.net/ioszhanghui/article/details/91045366
今日推荐