本文共 749 字,大约阅读时间需要 2 分钟。
语法一:
函数名 () { 代码块 return N }
语法二:
function 函数名 { 代码块 return N }
创建
执行
if [ condition ] #condition 值为true or false
then #条件为真的时候执行 commands #代码块 一行或者多行代码fi #语句结束if [ condition ] then #条件为真
commands1 #真 要执行代码块else #条件为假 commands2 #假 要执行的代码块fi 结束if [ condition 1] 满足第一个条件
then 真
command1 执行command1代码块
elif [ condition 2] 满足第二个条件 then 真commands2 执行command2代码块
else 如果条件都不满足commandsX 执行commandX代码块
fi 结束判断if [ !test1 ] then echo 'test1 is null'fi简写为[!test1 ] && echo 'test1 is null'if [! test2 ] then echo 'test2 is null'else echo 'test2!!'fi简写为[!test2] && echo 'test2 is null' || echo 'test2!!'
转载地址:http://vzxwb.baihongyu.com/