1 if條件判斷的格式
if [ 條件判斷 ];then.....;fi
if [ 條件判斷 ];then.....;else.....;fi
if [ 條件判斷1 ];then.....;elsif [ 條件判斷2 ].....;fi
shiyanlou:Desktop/ $ if [ -e brackets.desktop ];then echo "hello";fi [22:34:04]
hello
shiyanlou:Desktop/ $ if [ -e brackets.desktop ];then echo file exit;else echo file not exit;fi
file exit
2 如果是簡(jiǎn)單的分支判斷可以用&& ||替換if語(yǔ)句
file exit
shiyanlou:Desktop/ $ [ -e test.h ] && echo file exit || echo file not exit [22:44:38]
file not exit
shiyanlou:Desktop/ $