code7.txt

来自「前面我发的那本linuxprog的随书源代码」· 文本 代码 · 共 50 行

TXT
50
字号
Chapter 7

------------------------------
if Statement with One Criteria
------------------------------
if [ $Quantity -eq 100 ]
   then
   echo "The box is full."
fi

------------------------------
if Statement with Two Criteria
------------------------------
if [ $Quantity -eq 100 ] &&  [ $AvailableBoxes -lt 1 ]
   then
   echo "The box is full and you have no more boxes."
fi

-----------------
if else Statement 
-----------------
if  [ $Quantity -eq 100 ] 
   then
      echo "The box is full."
   else
      echo "The box is not full."
fi
if  [ $Quantity -ne 100 ]
   then
      echo "The box is full."
      echo "Sorry, you need to stop."
   else
      echo "The box is not full."
echo "Keep going!"
fi

-----------------
if elif Statement
-----------------
if [ $Quantity -eq 100 ] 
    then
      echo "The box is full."
   elif  [ $Quantity -eq 95 ]
    then
      echo "You can add 5 cookies to the box."
fi



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?