=~
的用法说明
~ 其实是对后面的正则表达式表示匹配的意思,如果匹配就输出1, 不匹配就输出0
通常只在 [[ ]] 中使用
例子
GitBranch=master
if [[ $1 =~ .*/$GitBranch$ ]];
then
echo $GitBranch ref received. Deploying $GitBranch branch to production...
else
echo Ref $1 successfully received. Doing nothing: only the master branch may be deployed on this server.
fi