主頁 >  其他 > Shell條件陳述句、if陳述句、case陳述句(小白都懂的詳解+邏輯圖釋)

Shell條件陳述句、if陳述句、case陳述句(小白都懂的詳解+邏輯圖釋)

2021-03-06 12:41:53 其他

Shell編程之條件陳述句

  • 條件測驗操作
    • test命令
    • 檔案測驗與整數測驗
      • 檔案測驗
      • 整數測驗
    • 字串測驗與邏輯測驗
      • 字串測驗
      • 邏輯測驗
  • if陳述句
    • if單分支陳述句
    • if雙分支陳述句
    • if多分支陳述句
  • case分支陳述句

條件測驗操作

test命令

  • 測驗運算式是否成立,若成立回傳0,否則回傳其他數值
  • 格式
    • 1.test 條件格式運算式
    • 2.[ 條件運算式 ]
      中括號兩邊都必須有空格
[root@localhost /]# test 8 = 9
[root@localhost /]# echo $?
1
[root@localhost /]# test 8 = 8
[root@localhost /]# echo $?
0
[root@localhost /]# [ 8 = 8 ]
[root@localhost /]# echo $?
0
[root@localhost /]# [ 8 = 9 ]
[root@localhost /]# echo $?
1
【中括號和運算子號兩邊都得有空格,若成立回傳0,否則回傳其他數值】

檔案測驗與整數測驗

檔案測驗

  • 格式:[ 運算子 檔案或目錄 ]
  • 常用的測驗運算子
運算子說明
-d測驗是否為目錄,且測驗該檔案是否存在(Directory)
-e測驗是否為為檔案且測驗該檔案是否存在(File)
-f測驗目錄或檔案是否存在(Exist)
-r測驗當前用戶是否有權限讀取(Read)
-w測驗當前用戶是否有權限寫入(Write)
-x測驗當前用戶是否有執行權限(eXcute)
[root@localhost opt]# touch wj
[root@localhost opt]# mkdir ml
[root@localhost opt]# ls
ml  rh  wj
[root@localhost opt]# [ -d ml ]&& echo 有       【測驗ml是否為目錄,"&&"并,與,而且通過echo輸出結果“有”】
有
[root@localhost opt]# [ -d wj ]
[root@localhost opt]# echo $?
1
[qz@localhost opt]$ ls -l
總用量 0
drwxr-xr-x. 2 root root 6 34 18:57 ml
drwxr-xr-x. 2 root root 6 326 2015 rh
--w-------. 1 root root 0 34 18:57 wj
[qz@localhost opt]$ [ -r wj ]
[qz@localhost opt]$ echo $?
1
[qz@localhost opt]$ [ -x wj ]
[qz@localhost opt]$ echo $?
1
【因為wj檔案只對】

整數測驗

  • 格式:[ 整數1 運算子 整數2 ]
運算子說明
-eq等于(Equal)
-ne不等于(Not Equal)
-gt大于(Greter Than)
-lt小于(Lesser Than)
-le小于或等于(Lesser or Equal)
-ge大于或等于(Greater or Equal)
[root@localhost ~]# Free=`free -m | grep "Mem:" | awk '{print $4}'`    
【通過grep檢索出包含“Men:”的指定字串并通過awk工具提取出所需的資料,最終使用反撇號提取該命令執行后的輸出結果賦值給Free】
[root@localhost ~]# echo $Free
86
[root@localhost ~]# [ $Free -lt 2048 ] && echo ${Free}M 
【Free變數獲取出的結果如果小于等于2048則輸出變數Free的值,單位為“M”】
86M

字串測驗與邏輯測驗

字串測驗

  • 格式
    • 1.[ 字串1 = 字串2 ]
    • 2.[ 字串1 != 字串2]
    • 3.[ -z 字串 ]
    • 4.[ -n 字串]
  • 常用測驗運算子
運算子說明
=字串內容相同
!=字串內容不同,!表示取反的意思
-z字串內容為空
未定義或者賦予空值的變數將視為空串
-n是否有字串
[root@localhost etc]# cd 
[root@localhost ~]# [ $PWD = $HOME ] && echo "當前在:$(pwd)路徑"
【如果該運算式成立則輸出“當前在‘提取pwd命令值’路徑”】
當前在:/root路徑
[root@localhost ~]# cd /etc/
[root@localhost etc]# [ $PWD = $HOME ] && echo "當前在:$(pwd)路徑"
[root@localhost etc]# echo $?
1
[root@localhost etc]# [ $PWD != $HOME ] && echo "當前在:$(pwd)路徑"
【如果該運算式不成立則輸出“當前在‘提取pwd命令值’路徑”】
當前在:/etc路徑

邏輯測驗

  • 格式
    • 1.[ 運算式1 ] 運算子 [ 運算式2 ] …
    • 2.命令1 運算子 命令2
  • 常用的測驗運算子
字串說明
-a
&&
邏輯與,而且的意思
運算子前后條件都需成立
-o
| |
邏輯或,或者的意思
只需前后運算子中一個成立即可
!邏輯否的意思
[root@localhost ~]# [ $a -ne 1 ] && [ $a != 3 ]  【在兩個[]之間用&&或者||[root@localhost ~]# echo $?
0
[root@localhost ~]# [ $a -ne 1 -a $a != 2 ]      【在同一個[]之間用-a 或者 -o】
[root@localhost ~]# echo $?
0
[root@localhost ~]# [[ 2 -lt 3 ]] && echo yes || no
yes
【因為2小于3的條件成立,且||運算子是第一個條件成立則echo輸出第一個值,所以是yes】
[root@localhost ~]# [[ 2 -gt 3 ]] && echo yes || echo no
no
【因為2大于3的條件未成立,所以&&運算子不成立,從而導致echo無法輸出“yes”,所以||運算子后面的“no”將被echo輸出】
[root@localhost ~]# [ 2 -gt 3 ] && echo yes || echo no && echo pass
no
pass
【因為2大于3的條件未成立,所以&&運算子不成立,從而導致echo無法輸出“yes”,所以||運算子后面的“no”將被echo輸出,所以第二個&&兩邊條件
都成立,故而pass會被echo輸出】
[root@localhost ~]# vim p.sh
[root@localhost ~]# chmod +x p.sh 
#!/bin/bash
ping -c 4 -i 1 -W 5 $1 &> /dev/null && echo "$1 在線" || echo "$1 不在線" 
:wq
[root@localhost ~]# ./p.sh www.baidu.com
www.baidu.com 在線
[root@localhost ~]# ./p.sh 192.11.111.10
192.11.111.10 不在線
【-c:發送包的個數  -i:發送包的間隔時間  -W:超時時間 -w:多少秒后停止ping命令操作】
【發送4個包,每次間隔1秒,5秒后超時,進行對baidu的ping包檢測其是否在線,并將標準輸出、標準
錯誤的內容保存到黑洞檔案,如果ping的通,則&&兩邊條件成立,則輸出第一個引數在線的資訊,如果
ping不通,則&&不成立,則輸出第一個引數不在線的資訊】

if陳述句

if單分支陳述句

  • 邏輯圖釋
<style>#mermaid-svg-NyIr25cZQ7mrg0d4 .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .label text{fill:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .node rect,#mermaid-svg-NyIr25cZQ7mrg0d4 .node circle,#mermaid-svg-NyIr25cZQ7mrg0d4 .node ellipse,#mermaid-svg-NyIr25cZQ7mrg0d4 .node polygon,#mermaid-svg-NyIr25cZQ7mrg0d4 .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-NyIr25cZQ7mrg0d4 .node .label{text-align:center;fill:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .node.clickable{cursor:pointer}#mermaid-svg-NyIr25cZQ7mrg0d4 .arrowheadPath{fill:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-NyIr25cZQ7mrg0d4 .flowchart-link{stroke:#333;fill:none}#mermaid-svg-NyIr25cZQ7mrg0d4 .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-NyIr25cZQ7mrg0d4 .edgeLabel rect{opacity:0.9}#mermaid-svg-NyIr25cZQ7mrg0d4 .edgeLabel span{color:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-NyIr25cZQ7mrg0d4 .cluster text{fill:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-NyIr25cZQ7mrg0d4 .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-NyIr25cZQ7mrg0d4 text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-NyIr25cZQ7mrg0d4 .actor-line{stroke:grey}#mermaid-svg-NyIr25cZQ7mrg0d4 .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .sequenceNumber{fill:#fff}#mermaid-svg-NyIr25cZQ7mrg0d4 #sequencenumber{fill:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 #crosshead path{fill:#333;stroke:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .messageText{fill:#333;stroke:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-NyIr25cZQ7mrg0d4 .labelText,#mermaid-svg-NyIr25cZQ7mrg0d4 .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-NyIr25cZQ7mrg0d4 .loopText,#mermaid-svg-NyIr25cZQ7mrg0d4 .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-NyIr25cZQ7mrg0d4 .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-NyIr25cZQ7mrg0d4 .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-NyIr25cZQ7mrg0d4 .noteText,#mermaid-svg-NyIr25cZQ7mrg0d4 .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-NyIr25cZQ7mrg0d4 .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-NyIr25cZQ7mrg0d4 .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-NyIr25cZQ7mrg0d4 .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-NyIr25cZQ7mrg0d4 .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-NyIr25cZQ7mrg0d4 .section{stroke:none;opacity:0.2}#mermaid-svg-NyIr25cZQ7mrg0d4 .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-NyIr25cZQ7mrg0d4 .section2{fill:#fff400}#mermaid-svg-NyIr25cZQ7mrg0d4 .section1,#mermaid-svg-NyIr25cZQ7mrg0d4 .section3{fill:#fff;opacity:0.2}#mermaid-svg-NyIr25cZQ7mrg0d4 .sectionTitle0{fill:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .sectionTitle1{fill:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .sectionTitle2{fill:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .sectionTitle3{fill:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-NyIr25cZQ7mrg0d4 .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-NyIr25cZQ7mrg0d4 .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-NyIr25cZQ7mrg0d4 .grid path{stroke-width:0}#mermaid-svg-NyIr25cZQ7mrg0d4 .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-NyIr25cZQ7mrg0d4 .task{stroke-width:2}#mermaid-svg-NyIr25cZQ7mrg0d4 .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-NyIr25cZQ7mrg0d4 .taskText:not([font-size]){font-size:11px}#mermaid-svg-NyIr25cZQ7mrg0d4 .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-NyIr25cZQ7mrg0d4 .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-NyIr25cZQ7mrg0d4 .task.clickable{cursor:pointer}#mermaid-svg-NyIr25cZQ7mrg0d4 .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-NyIr25cZQ7mrg0d4 .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-NyIr25cZQ7mrg0d4 .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-NyIr25cZQ7mrg0d4 .taskText0,#mermaid-svg-NyIr25cZQ7mrg0d4 .taskText1,#mermaid-svg-NyIr25cZQ7mrg0d4 .taskText2,#mermaid-svg-NyIr25cZQ7mrg0d4 .taskText3{fill:#fff}#mermaid-svg-NyIr25cZQ7mrg0d4 .task0,#mermaid-svg-NyIr25cZQ7mrg0d4 .task1,#mermaid-svg-NyIr25cZQ7mrg0d4 .task2,#mermaid-svg-NyIr25cZQ7mrg0d4 .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-NyIr25cZQ7mrg0d4 .taskTextOutside0,#mermaid-svg-NyIr25cZQ7mrg0d4 .taskTextOutside2{fill:#000}#mermaid-svg-NyIr25cZQ7mrg0d4 .taskTextOutside1,#mermaid-svg-NyIr25cZQ7mrg0d4 .taskTextOutside3{fill:#000}#mermaid-svg-NyIr25cZQ7mrg0d4 .active0,#mermaid-svg-NyIr25cZQ7mrg0d4 .active1,#mermaid-svg-NyIr25cZQ7mrg0d4 .active2,#mermaid-svg-NyIr25cZQ7mrg0d4 .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-NyIr25cZQ7mrg0d4 .activeText0,#mermaid-svg-NyIr25cZQ7mrg0d4 .activeText1,#mermaid-svg-NyIr25cZQ7mrg0d4 .activeText2,#mermaid-svg-NyIr25cZQ7mrg0d4 .activeText3{fill:#000 !important}#mermaid-svg-NyIr25cZQ7mrg0d4 .done0,#mermaid-svg-NyIr25cZQ7mrg0d4 .done1,#mermaid-svg-NyIr25cZQ7mrg0d4 .done2,#mermaid-svg-NyIr25cZQ7mrg0d4 .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-NyIr25cZQ7mrg0d4 .doneText0,#mermaid-svg-NyIr25cZQ7mrg0d4 .doneText1,#mermaid-svg-NyIr25cZQ7mrg0d4 .doneText2,#mermaid-svg-NyIr25cZQ7mrg0d4 .doneText3{fill:#000 !important}#mermaid-svg-NyIr25cZQ7mrg0d4 .crit0,#mermaid-svg-NyIr25cZQ7mrg0d4 .crit1,#mermaid-svg-NyIr25cZQ7mrg0d4 .crit2,#mermaid-svg-NyIr25cZQ7mrg0d4 .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-NyIr25cZQ7mrg0d4 .activeCrit0,#mermaid-svg-NyIr25cZQ7mrg0d4 .activeCrit1,#mermaid-svg-NyIr25cZQ7mrg0d4 .activeCrit2,#mermaid-svg-NyIr25cZQ7mrg0d4 .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-NyIr25cZQ7mrg0d4 .doneCrit0,#mermaid-svg-NyIr25cZQ7mrg0d4 .doneCrit1,#mermaid-svg-NyIr25cZQ7mrg0d4 .doneCrit2,#mermaid-svg-NyIr25cZQ7mrg0d4 .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-NyIr25cZQ7mrg0d4 .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-NyIr25cZQ7mrg0d4 .milestoneText{font-style:italic}#mermaid-svg-NyIr25cZQ7mrg0d4 .doneCritText0,#mermaid-svg-NyIr25cZQ7mrg0d4 .doneCritText1,#mermaid-svg-NyIr25cZQ7mrg0d4 .doneCritText2,#mermaid-svg-NyIr25cZQ7mrg0d4 .doneCritText3{fill:#000 !important}#mermaid-svg-NyIr25cZQ7mrg0d4 .activeCritText0,#mermaid-svg-NyIr25cZQ7mrg0d4 .activeCritText1,#mermaid-svg-NyIr25cZQ7mrg0d4 .activeCritText2,#mermaid-svg-NyIr25cZQ7mrg0d4 .activeCritText3{fill:#000 !important}#mermaid-svg-NyIr25cZQ7mrg0d4 .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-NyIr25cZQ7mrg0d4 g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-NyIr25cZQ7mrg0d4 g.classGroup text .title{font-weight:bolder}#mermaid-svg-NyIr25cZQ7mrg0d4 g.clickable{cursor:pointer}#mermaid-svg-NyIr25cZQ7mrg0d4 g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-NyIr25cZQ7mrg0d4 g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-NyIr25cZQ7mrg0d4 .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-NyIr25cZQ7mrg0d4 .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-NyIr25cZQ7mrg0d4 .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-NyIr25cZQ7mrg0d4 .dashed-line{stroke-dasharray:3}#mermaid-svg-NyIr25cZQ7mrg0d4 #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-NyIr25cZQ7mrg0d4 #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-NyIr25cZQ7mrg0d4 #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-NyIr25cZQ7mrg0d4 #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-NyIr25cZQ7mrg0d4 #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-NyIr25cZQ7mrg0d4 #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-NyIr25cZQ7mrg0d4 #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-NyIr25cZQ7mrg0d4 #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-NyIr25cZQ7mrg0d4 .commit-id,#mermaid-svg-NyIr25cZQ7mrg0d4 .commit-msg,#mermaid-svg-NyIr25cZQ7mrg0d4 .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-NyIr25cZQ7mrg0d4 .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-NyIr25cZQ7mrg0d4 .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-NyIr25cZQ7mrg0d4 g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-NyIr25cZQ7mrg0d4 g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-NyIr25cZQ7mrg0d4 g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-NyIr25cZQ7mrg0d4 g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-NyIr25cZQ7mrg0d4 g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-NyIr25cZQ7mrg0d4 .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-NyIr25cZQ7mrg0d4 .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-NyIr25cZQ7mrg0d4 .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-NyIr25cZQ7mrg0d4 .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-NyIr25cZQ7mrg0d4 .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-NyIr25cZQ7mrg0d4 .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-NyIr25cZQ7mrg0d4 .edgeLabel text{fill:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-NyIr25cZQ7mrg0d4 .node circle.state-start{fill:black;stroke:black}#mermaid-svg-NyIr25cZQ7mrg0d4 .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-NyIr25cZQ7mrg0d4 #statediagram-barbEnd{fill:#9370db}#mermaid-svg-NyIr25cZQ7mrg0d4 .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-NyIr25cZQ7mrg0d4 .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-NyIr25cZQ7mrg0d4 .statediagram-state .divider{stroke:#9370db}#mermaid-svg-NyIr25cZQ7mrg0d4 .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-NyIr25cZQ7mrg0d4 .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-NyIr25cZQ7mrg0d4 .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-NyIr25cZQ7mrg0d4 .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-NyIr25cZQ7mrg0d4 .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-NyIr25cZQ7mrg0d4 .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-NyIr25cZQ7mrg0d4 .note-edge{stroke-dasharray:5}#mermaid-svg-NyIr25cZQ7mrg0d4 .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-NyIr25cZQ7mrg0d4 .error-icon{fill:#522}#mermaid-svg-NyIr25cZQ7mrg0d4 .error-text{fill:#522;stroke:#522}#mermaid-svg-NyIr25cZQ7mrg0d4 .edge-thickness-normal{stroke-width:2px}#mermaid-svg-NyIr25cZQ7mrg0d4 .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-NyIr25cZQ7mrg0d4 .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-NyIr25cZQ7mrg0d4 .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-NyIr25cZQ7mrg0d4 .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-NyIr25cZQ7mrg0d4 .marker{fill:#333}#mermaid-svg-NyIr25cZQ7mrg0d4 .marker.cross{stroke:#333} :root { --mermaid-font-family: "trebuchet ms", verdana, arial;}</style> <style>#mermaid-svg-NyIr25cZQ7mrg0d4 { color: rgba(0, 0, 0, 0.75); font: ; }</style>
條件成立
then
if條件測驗操作
條件運算式
命令序列...
fi 結束判斷
條件不成立
[root@localhost ~]# if [ 3 -gt 2 ]
> then
> echo "ok"
> fi
ok
[root@localhost ~]# if [ 3 -gt 2 ]; then echo "ok"; fi
ok
[root@localhost ~]# [ 3 -gt 2 ] && echo "ok"
ok
【單分支if陳述句中&&也實作簡單的if陳述句判斷】

if雙分支陳述句

  • 邏輯圖釋
<style>#mermaid-svg-DA4z1J2CAh2XYHFV .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .label text{fill:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .node rect,#mermaid-svg-DA4z1J2CAh2XYHFV .node circle,#mermaid-svg-DA4z1J2CAh2XYHFV .node ellipse,#mermaid-svg-DA4z1J2CAh2XYHFV .node polygon,#mermaid-svg-DA4z1J2CAh2XYHFV .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-DA4z1J2CAh2XYHFV .node .label{text-align:center;fill:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .node.clickable{cursor:pointer}#mermaid-svg-DA4z1J2CAh2XYHFV .arrowheadPath{fill:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-DA4z1J2CAh2XYHFV .flowchart-link{stroke:#333;fill:none}#mermaid-svg-DA4z1J2CAh2XYHFV .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-DA4z1J2CAh2XYHFV .edgeLabel rect{opacity:0.9}#mermaid-svg-DA4z1J2CAh2XYHFV .edgeLabel span{color:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-DA4z1J2CAh2XYHFV .cluster text{fill:#333}#mermaid-svg-DA4z1J2CAh2XYHFV div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-DA4z1J2CAh2XYHFV .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-DA4z1J2CAh2XYHFV text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-DA4z1J2CAh2XYHFV .actor-line{stroke:grey}#mermaid-svg-DA4z1J2CAh2XYHFV .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-DA4z1J2CAh2XYHFV #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .sequenceNumber{fill:#fff}#mermaid-svg-DA4z1J2CAh2XYHFV #sequencenumber{fill:#333}#mermaid-svg-DA4z1J2CAh2XYHFV #crosshead path{fill:#333;stroke:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .messageText{fill:#333;stroke:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-DA4z1J2CAh2XYHFV .labelText,#mermaid-svg-DA4z1J2CAh2XYHFV .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-DA4z1J2CAh2XYHFV .loopText,#mermaid-svg-DA4z1J2CAh2XYHFV .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-DA4z1J2CAh2XYHFV .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-DA4z1J2CAh2XYHFV .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-DA4z1J2CAh2XYHFV .noteText,#mermaid-svg-DA4z1J2CAh2XYHFV .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-DA4z1J2CAh2XYHFV .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-DA4z1J2CAh2XYHFV .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-DA4z1J2CAh2XYHFV .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-DA4z1J2CAh2XYHFV .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-DA4z1J2CAh2XYHFV .section{stroke:none;opacity:0.2}#mermaid-svg-DA4z1J2CAh2XYHFV .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-DA4z1J2CAh2XYHFV .section2{fill:#fff400}#mermaid-svg-DA4z1J2CAh2XYHFV .section1,#mermaid-svg-DA4z1J2CAh2XYHFV .section3{fill:#fff;opacity:0.2}#mermaid-svg-DA4z1J2CAh2XYHFV .sectionTitle0{fill:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .sectionTitle1{fill:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .sectionTitle2{fill:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .sectionTitle3{fill:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-DA4z1J2CAh2XYHFV .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-DA4z1J2CAh2XYHFV .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-DA4z1J2CAh2XYHFV .grid path{stroke-width:0}#mermaid-svg-DA4z1J2CAh2XYHFV .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-DA4z1J2CAh2XYHFV .task{stroke-width:2}#mermaid-svg-DA4z1J2CAh2XYHFV .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-DA4z1J2CAh2XYHFV .taskText:not([font-size]){font-size:11px}#mermaid-svg-DA4z1J2CAh2XYHFV .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-DA4z1J2CAh2XYHFV .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-DA4z1J2CAh2XYHFV .task.clickable{cursor:pointer}#mermaid-svg-DA4z1J2CAh2XYHFV .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-DA4z1J2CAh2XYHFV .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-DA4z1J2CAh2XYHFV .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-DA4z1J2CAh2XYHFV .taskText0,#mermaid-svg-DA4z1J2CAh2XYHFV .taskText1,#mermaid-svg-DA4z1J2CAh2XYHFV .taskText2,#mermaid-svg-DA4z1J2CAh2XYHFV .taskText3{fill:#fff}#mermaid-svg-DA4z1J2CAh2XYHFV .task0,#mermaid-svg-DA4z1J2CAh2XYHFV .task1,#mermaid-svg-DA4z1J2CAh2XYHFV .task2,#mermaid-svg-DA4z1J2CAh2XYHFV .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-DA4z1J2CAh2XYHFV .taskTextOutside0,#mermaid-svg-DA4z1J2CAh2XYHFV .taskTextOutside2{fill:#000}#mermaid-svg-DA4z1J2CAh2XYHFV .taskTextOutside1,#mermaid-svg-DA4z1J2CAh2XYHFV .taskTextOutside3{fill:#000}#mermaid-svg-DA4z1J2CAh2XYHFV .active0,#mermaid-svg-DA4z1J2CAh2XYHFV .active1,#mermaid-svg-DA4z1J2CAh2XYHFV .active2,#mermaid-svg-DA4z1J2CAh2XYHFV .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-DA4z1J2CAh2XYHFV .activeText0,#mermaid-svg-DA4z1J2CAh2XYHFV .activeText1,#mermaid-svg-DA4z1J2CAh2XYHFV .activeText2,#mermaid-svg-DA4z1J2CAh2XYHFV .activeText3{fill:#000 !important}#mermaid-svg-DA4z1J2CAh2XYHFV .done0,#mermaid-svg-DA4z1J2CAh2XYHFV .done1,#mermaid-svg-DA4z1J2CAh2XYHFV .done2,#mermaid-svg-DA4z1J2CAh2XYHFV .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-DA4z1J2CAh2XYHFV .doneText0,#mermaid-svg-DA4z1J2CAh2XYHFV .doneText1,#mermaid-svg-DA4z1J2CAh2XYHFV .doneText2,#mermaid-svg-DA4z1J2CAh2XYHFV .doneText3{fill:#000 !important}#mermaid-svg-DA4z1J2CAh2XYHFV .crit0,#mermaid-svg-DA4z1J2CAh2XYHFV .crit1,#mermaid-svg-DA4z1J2CAh2XYHFV .crit2,#mermaid-svg-DA4z1J2CAh2XYHFV .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-DA4z1J2CAh2XYHFV .activeCrit0,#mermaid-svg-DA4z1J2CAh2XYHFV .activeCrit1,#mermaid-svg-DA4z1J2CAh2XYHFV .activeCrit2,#mermaid-svg-DA4z1J2CAh2XYHFV .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-DA4z1J2CAh2XYHFV .doneCrit0,#mermaid-svg-DA4z1J2CAh2XYHFV .doneCrit1,#mermaid-svg-DA4z1J2CAh2XYHFV .doneCrit2,#mermaid-svg-DA4z1J2CAh2XYHFV .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-DA4z1J2CAh2XYHFV .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-DA4z1J2CAh2XYHFV .milestoneText{font-style:italic}#mermaid-svg-DA4z1J2CAh2XYHFV .doneCritText0,#mermaid-svg-DA4z1J2CAh2XYHFV .doneCritText1,#mermaid-svg-DA4z1J2CAh2XYHFV .doneCritText2,#mermaid-svg-DA4z1J2CAh2XYHFV .doneCritText3{fill:#000 !important}#mermaid-svg-DA4z1J2CAh2XYHFV .activeCritText0,#mermaid-svg-DA4z1J2CAh2XYHFV .activeCritText1,#mermaid-svg-DA4z1J2CAh2XYHFV .activeCritText2,#mermaid-svg-DA4z1J2CAh2XYHFV .activeCritText3{fill:#000 !important}#mermaid-svg-DA4z1J2CAh2XYHFV .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-DA4z1J2CAh2XYHFV g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-DA4z1J2CAh2XYHFV g.classGroup text .title{font-weight:bolder}#mermaid-svg-DA4z1J2CAh2XYHFV g.clickable{cursor:pointer}#mermaid-svg-DA4z1J2CAh2XYHFV g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-DA4z1J2CAh2XYHFV g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-DA4z1J2CAh2XYHFV .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-DA4z1J2CAh2XYHFV .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-DA4z1J2CAh2XYHFV .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-DA4z1J2CAh2XYHFV .dashed-line{stroke-dasharray:3}#mermaid-svg-DA4z1J2CAh2XYHFV #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-DA4z1J2CAh2XYHFV #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-DA4z1J2CAh2XYHFV #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-DA4z1J2CAh2XYHFV #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-DA4z1J2CAh2XYHFV #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-DA4z1J2CAh2XYHFV #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-DA4z1J2CAh2XYHFV #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-DA4z1J2CAh2XYHFV #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-DA4z1J2CAh2XYHFV .commit-id,#mermaid-svg-DA4z1J2CAh2XYHFV .commit-msg,#mermaid-svg-DA4z1J2CAh2XYHFV .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-DA4z1J2CAh2XYHFV .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-DA4z1J2CAh2XYHFV .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-DA4z1J2CAh2XYHFV g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-DA4z1J2CAh2XYHFV g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-DA4z1J2CAh2XYHFV g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-DA4z1J2CAh2XYHFV g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-DA4z1J2CAh2XYHFV g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-DA4z1J2CAh2XYHFV g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-DA4z1J2CAh2XYHFV .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-DA4z1J2CAh2XYHFV .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-DA4z1J2CAh2XYHFV .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-DA4z1J2CAh2XYHFV .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-DA4z1J2CAh2XYHFV .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-DA4z1J2CAh2XYHFV .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-DA4z1J2CAh2XYHFV .edgeLabel text{fill:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-DA4z1J2CAh2XYHFV .node circle.state-start{fill:black;stroke:black}#mermaid-svg-DA4z1J2CAh2XYHFV .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-DA4z1J2CAh2XYHFV #statediagram-barbEnd{fill:#9370db}#mermaid-svg-DA4z1J2CAh2XYHFV .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-DA4z1J2CAh2XYHFV .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-DA4z1J2CAh2XYHFV .statediagram-state .divider{stroke:#9370db}#mermaid-svg-DA4z1J2CAh2XYHFV .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-DA4z1J2CAh2XYHFV .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-DA4z1J2CAh2XYHFV .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-DA4z1J2CAh2XYHFV .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-DA4z1J2CAh2XYHFV .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-DA4z1J2CAh2XYHFV .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-DA4z1J2CAh2XYHFV .note-edge{stroke-dasharray:5}#mermaid-svg-DA4z1J2CAh2XYHFV .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-DA4z1J2CAh2XYHFV .error-icon{fill:#522}#mermaid-svg-DA4z1J2CAh2XYHFV .error-text{fill:#522;stroke:#522}#mermaid-svg-DA4z1J2CAh2XYHFV .edge-thickness-normal{stroke-width:2px}#mermaid-svg-DA4z1J2CAh2XYHFV .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-DA4z1J2CAh2XYHFV .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-DA4z1J2CAh2XYHFV .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-DA4z1J2CAh2XYHFV .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-DA4z1J2CAh2XYHFV .marker{fill:#333}#mermaid-svg-DA4z1J2CAh2XYHFV .marker.cross{stroke:#333} :root { --mermaid-font-family: "trebuchet ms", verdana, arial;}</style> <style>#mermaid-svg-DA4z1J2CAh2XYHFV { color: rgba(0, 0, 0, 0.75); font: ; }</style>
條件成立
then
條件不成立
else
if條件測驗操作
條件運算式
命令序列1...
fi結束判斷
命令序列2...
[root@localhost ~]# vim text.sh

#!/bin/bash

netstat -natp | grep ":80" &> /dev/null                   【檢測80埠網路通信情況,并把資料丟入黑洞】

if [ $? -eq 0 ]                                           【執行$?等于0條件運算式】    
then                                                      【如果$?等于0條件成立則輸出“httpd服務正在運行中”結果】
  echo "httpd服務正在運行中"

else                                                      【如果$?等于0條件不成立則輸出“httpd服務未在運行,請啟動該服務”結果】
  echo "htppd服務未在運行,請啟動該服務"

fi
:wq
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# ./text.sh 
httpd服務正在運行中
[root@localhost ~]# systemctl stop httpd
httpd服務未在運行,請啟動該服務

if多分支陳述句

  • 邏輯圖釋
<style>#mermaid-svg-ZKV0K2RFaHhyp8lZ .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .label text{fill:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .node rect,#mermaid-svg-ZKV0K2RFaHhyp8lZ .node circle,#mermaid-svg-ZKV0K2RFaHhyp8lZ .node ellipse,#mermaid-svg-ZKV0K2RFaHhyp8lZ .node polygon,#mermaid-svg-ZKV0K2RFaHhyp8lZ .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .node .label{text-align:center;fill:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .node.clickable{cursor:pointer}#mermaid-svg-ZKV0K2RFaHhyp8lZ .arrowheadPath{fill:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .flowchart-link{stroke:#333;fill:none}#mermaid-svg-ZKV0K2RFaHhyp8lZ .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-ZKV0K2RFaHhyp8lZ .edgeLabel rect{opacity:0.9}#mermaid-svg-ZKV0K2RFaHhyp8lZ .edgeLabel span{color:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .cluster text{fill:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-ZKV0K2RFaHhyp8lZ .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-ZKV0K2RFaHhyp8lZ text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-ZKV0K2RFaHhyp8lZ .actor-line{stroke:grey}#mermaid-svg-ZKV0K2RFaHhyp8lZ .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .sequenceNumber{fill:#fff}#mermaid-svg-ZKV0K2RFaHhyp8lZ #sequencenumber{fill:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ #crosshead path{fill:#333;stroke:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .messageText{fill:#333;stroke:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-ZKV0K2RFaHhyp8lZ .labelText,#mermaid-svg-ZKV0K2RFaHhyp8lZ .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-ZKV0K2RFaHhyp8lZ .loopText,#mermaid-svg-ZKV0K2RFaHhyp8lZ .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-ZKV0K2RFaHhyp8lZ .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-ZKV0K2RFaHhyp8lZ .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-ZKV0K2RFaHhyp8lZ .noteText,#mermaid-svg-ZKV0K2RFaHhyp8lZ .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-ZKV0K2RFaHhyp8lZ .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-ZKV0K2RFaHhyp8lZ .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-ZKV0K2RFaHhyp8lZ .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-ZKV0K2RFaHhyp8lZ .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ZKV0K2RFaHhyp8lZ .section{stroke:none;opacity:0.2}#mermaid-svg-ZKV0K2RFaHhyp8lZ .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-ZKV0K2RFaHhyp8lZ .section2{fill:#fff400}#mermaid-svg-ZKV0K2RFaHhyp8lZ .section1,#mermaid-svg-ZKV0K2RFaHhyp8lZ .section3{fill:#fff;opacity:0.2}#mermaid-svg-ZKV0K2RFaHhyp8lZ .sectionTitle0{fill:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .sectionTitle1{fill:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .sectionTitle2{fill:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .sectionTitle3{fill:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ZKV0K2RFaHhyp8lZ .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-ZKV0K2RFaHhyp8lZ .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ZKV0K2RFaHhyp8lZ .grid path{stroke-width:0}#mermaid-svg-ZKV0K2RFaHhyp8lZ .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .task{stroke-width:2}#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskText:not([font-size]){font-size:11px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .task.clickable{cursor:pointer}#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskText0,#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskText1,#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskText2,#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskText3{fill:#fff}#mermaid-svg-ZKV0K2RFaHhyp8lZ .task0,#mermaid-svg-ZKV0K2RFaHhyp8lZ .task1,#mermaid-svg-ZKV0K2RFaHhyp8lZ .task2,#mermaid-svg-ZKV0K2RFaHhyp8lZ .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskTextOutside0,#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskTextOutside2{fill:#000}#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskTextOutside1,#mermaid-svg-ZKV0K2RFaHhyp8lZ .taskTextOutside3{fill:#000}#mermaid-svg-ZKV0K2RFaHhyp8lZ .active0,#mermaid-svg-ZKV0K2RFaHhyp8lZ .active1,#mermaid-svg-ZKV0K2RFaHhyp8lZ .active2,#mermaid-svg-ZKV0K2RFaHhyp8lZ .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-ZKV0K2RFaHhyp8lZ .activeText0,#mermaid-svg-ZKV0K2RFaHhyp8lZ .activeText1,#mermaid-svg-ZKV0K2RFaHhyp8lZ .activeText2,#mermaid-svg-ZKV0K2RFaHhyp8lZ .activeText3{fill:#000 !important}#mermaid-svg-ZKV0K2RFaHhyp8lZ .done0,#mermaid-svg-ZKV0K2RFaHhyp8lZ .done1,#mermaid-svg-ZKV0K2RFaHhyp8lZ .done2,#mermaid-svg-ZKV0K2RFaHhyp8lZ .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-ZKV0K2RFaHhyp8lZ .doneText0,#mermaid-svg-ZKV0K2RFaHhyp8lZ .doneText1,#mermaid-svg-ZKV0K2RFaHhyp8lZ .doneText2,#mermaid-svg-ZKV0K2RFaHhyp8lZ .doneText3{fill:#000 !important}#mermaid-svg-ZKV0K2RFaHhyp8lZ .crit0,#mermaid-svg-ZKV0K2RFaHhyp8lZ .crit1,#mermaid-svg-ZKV0K2RFaHhyp8lZ .crit2,#mermaid-svg-ZKV0K2RFaHhyp8lZ .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-ZKV0K2RFaHhyp8lZ .activeCrit0,#mermaid-svg-ZKV0K2RFaHhyp8lZ .activeCrit1,#mermaid-svg-ZKV0K2RFaHhyp8lZ .activeCrit2,#mermaid-svg-ZKV0K2RFaHhyp8lZ .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-ZKV0K2RFaHhyp8lZ .doneCrit0,#mermaid-svg-ZKV0K2RFaHhyp8lZ .doneCrit1,#mermaid-svg-ZKV0K2RFaHhyp8lZ .doneCrit2,#mermaid-svg-ZKV0K2RFaHhyp8lZ .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-ZKV0K2RFaHhyp8lZ .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-ZKV0K2RFaHhyp8lZ .milestoneText{font-style:italic}#mermaid-svg-ZKV0K2RFaHhyp8lZ .doneCritText0,#mermaid-svg-ZKV0K2RFaHhyp8lZ .doneCritText1,#mermaid-svg-ZKV0K2RFaHhyp8lZ .doneCritText2,#mermaid-svg-ZKV0K2RFaHhyp8lZ .doneCritText3{fill:#000 !important}#mermaid-svg-ZKV0K2RFaHhyp8lZ .activeCritText0,#mermaid-svg-ZKV0K2RFaHhyp8lZ .activeCritText1,#mermaid-svg-ZKV0K2RFaHhyp8lZ .activeCritText2,#mermaid-svg-ZKV0K2RFaHhyp8lZ .activeCritText3{fill:#000 !important}#mermaid-svg-ZKV0K2RFaHhyp8lZ .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ZKV0K2RFaHhyp8lZ g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-ZKV0K2RFaHhyp8lZ g.classGroup text .title{font-weight:bolder}#mermaid-svg-ZKV0K2RFaHhyp8lZ g.clickable{cursor:pointer}#mermaid-svg-ZKV0K2RFaHhyp8lZ g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-ZKV0K2RFaHhyp8lZ g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-ZKV0K2RFaHhyp8lZ .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-ZKV0K2RFaHhyp8lZ .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-ZKV0K2RFaHhyp8lZ .dashed-line{stroke-dasharray:3}#mermaid-svg-ZKV0K2RFaHhyp8lZ #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ZKV0K2RFaHhyp8lZ #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ZKV0K2RFaHhyp8lZ #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-ZKV0K2RFaHhyp8lZ #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-ZKV0K2RFaHhyp8lZ #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ZKV0K2RFaHhyp8lZ #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ZKV0K2RFaHhyp8lZ #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ZKV0K2RFaHhyp8lZ #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ZKV0K2RFaHhyp8lZ .commit-id,#mermaid-svg-ZKV0K2RFaHhyp8lZ .commit-msg,#mermaid-svg-ZKV0K2RFaHhyp8lZ .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ZKV0K2RFaHhyp8lZ .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ZKV0K2RFaHhyp8lZ .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ZKV0K2RFaHhyp8lZ g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ZKV0K2RFaHhyp8lZ g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-ZKV0K2RFaHhyp8lZ g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-ZKV0K2RFaHhyp8lZ g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-ZKV0K2RFaHhyp8lZ g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-ZKV0K2RFaHhyp8lZ .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-ZKV0K2RFaHhyp8lZ .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-ZKV0K2RFaHhyp8lZ .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-ZKV0K2RFaHhyp8lZ .edgeLabel text{fill:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ZKV0K2RFaHhyp8lZ .node circle.state-start{fill:black;stroke:black}#mermaid-svg-ZKV0K2RFaHhyp8lZ .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-ZKV0K2RFaHhyp8lZ #statediagram-barbEnd{fill:#9370db}#mermaid-svg-ZKV0K2RFaHhyp8lZ .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .statediagram-state .divider{stroke:#9370db}#mermaid-svg-ZKV0K2RFaHhyp8lZ .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-ZKV0K2RFaHhyp8lZ .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-ZKV0K2RFaHhyp8lZ .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-ZKV0K2RFaHhyp8lZ .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-ZKV0K2RFaHhyp8lZ .note-edge{stroke-dasharray:5}#mermaid-svg-ZKV0K2RFaHhyp8lZ .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-ZKV0K2RFaHhyp8lZ .error-icon{fill:#522}#mermaid-svg-ZKV0K2RFaHhyp8lZ .error-text{fill:#522;stroke:#522}#mermaid-svg-ZKV0K2RFaHhyp8lZ .edge-thickness-normal{stroke-width:2px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-ZKV0K2RFaHhyp8lZ .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-ZKV0K2RFaHhyp8lZ .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-ZKV0K2RFaHhyp8lZ .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-ZKV0K2RFaHhyp8lZ .marker{fill:#333}#mermaid-svg-ZKV0K2RFaHhyp8lZ .marker.cross{stroke:#333} :root { --mermaid-font-family: "trebuchet ms", verdana, arial;}</style> <style>#mermaid-svg-ZKV0K2RFaHhyp8lZ { color: rgba(0, 0, 0, 0.75); font: ; }</style>
條件成立
then
條件成立
then
條件不成立
else
if條件測驗操作1
條件運算式1
命令序列1...
fi結束判斷
elif
if條件測驗操作2
條件運算式2
命令序列2...
命令序列n...
[root@localhost ~]# vim text1.sh
#!/bin/bash
read -p "輸入你的分數:" score            【使用read -p命令把鍵盤輸入的值賦值給score變數】

if [ $score -ge 85 -a $score -le 100 ]
then
  echo "你的分數為:${score},真棒!"

elif [ $score -ge 70 ] && [ $score -lt 85 ];then
  echo "你的分數為:${score},請再接再厲!"

elif [[ $score -lt 70 && $score -ge 0 ]];then
  echo “你的分數為:${score} ,不及格!else
  echo "輸入有誤,請重新輸入!"

fi
:wq
[root@localhost ~]# chmod +x text1.sh 
[root@localhost ~]# ./text1.sh 
輸入你的分數:69
“你的分數為:69 ,loser![root@localhost ~]# ./text1.sh 
輸入你的分數:89
你的分數為:89,真棒!
[root@localhost ~]# ./text1.sh 
輸入你的分數:0
“你的分數為:0 ,loser![root@localhost ~]# ./text1.sh 
輸入你的分數:70
你的分數為:70,請再接再厲!
[root@localhost ~]# ./text1.sh 
輸入你的分數:80
你的分數為:80,請再接再厲!

case分支陳述句

  • 邏輯圖釋

在這里插入圖片描述

[root@localhost ~]# vim text1.sh

#!/bin/bash
read -p "輸入你的分數:" score

[ $score -ge 85 -a $score -le 100 ] && a="great"
[ $score -ge 70 -a $score -le 84 ] && a="good"
[ $score -ge 0 -a $score -le 69 ] && a="false"

case $a in
great)
  echo "你的分數為:${score},真棒!"
;;

good)
  echo "你的分數為:${score},請再接再厲!"
;;

false)
  echo “你的分數為:${score} ,loser!;;


*)
  echo "輸入有誤,請重新輸入!"

esac

:wq
[root@localhost ~]# ./text1.sh 
輸入你的分數:100
你的分數為:100,真棒!
[root@localhost ~]# ./text1.sh 
輸入你的分數:70
你的分數為:70,請再接再厲!
[root@localhost ~]# ./text1.sh 
輸入你的分數:0
“你的分數為:0 ,loser!

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/266756.html

標籤:其他

上一篇:github太慢甚至無法訪問

下一篇:Linux基礎回顧

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 網閘典型架構簡述

    網閘架構一般分為兩種:三主機的三系統架構網閘和雙主機的2+1架構網閘。 三主機架構分別為內端機、外端機和仲裁機。三機無論從軟體和硬體上均各自獨立。首先從硬體上來看,三機都用各自獨立的主板、記憶體及存盤設備。從軟體上來看,三機有各自獨立的作業系統。這樣能達到完全的三機獨立。對于“2+1”系統,“2”分為 ......

    uj5u.com 2020-09-10 02:00:44 more
  • 如何從xshell上傳檔案到centos linux虛擬機里

    如何從xshell上傳檔案到centos linux虛擬機里及:虛擬機CentOs下執行 yum -y install lrzsz命令,出現錯誤:鏡像無法找到軟體包 前言 一、安裝lrzsz步驟 二、上傳檔案 三、遇到的問題及解決方案 總結 前言 提示:其實很簡單,往虛擬機上安裝一個上傳檔案的工具 ......

    uj5u.com 2020-09-10 02:00:47 more
  • 一、SQLMAP入門

    一、SQLMAP入門 1、判斷是否存在注入 sqlmap.py -u 網址/id=1 id=1不可缺少。當注入點后面的引數大于兩個時。需要加雙引號, sqlmap.py -u "網址/id=1&uid=1" 2、判斷文本中的請求是否存在注入 從文本中加載http請求,SQLMAP可以從一個文本檔案中 ......

    uj5u.com 2020-09-10 02:00:50 more
  • Metasploit 簡單使用教程

    metasploit 簡單使用教程 浩先生, 2020-08-28 16:18:25 分類專欄: kail 網路安全 linux 文章標簽: linux資訊安全 編輯 著作權 metasploit 使用教程 前言 一、Metasploit是什么? 二、準備作業 三、具體步驟 前言 Msfconsole ......

    uj5u.com 2020-09-10 02:00:53 more
  • 游戲逆向之驅動層與用戶層通訊

    驅動層代碼: #pragma once #include <ntifs.h> #define add_code CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) /* 更多游戲逆向視頻www.yxfzedu.com ......

    uj5u.com 2020-09-10 02:00:56 more
  • 北斗電力時鐘(北斗授時服務器)讓網路資料更精準

    北斗電力時鐘(北斗授時服務器)讓網路資料更精準 北斗電力時鐘(北斗授時服務器)讓網路資料更精準 京準電子科技官微——ahjzsz 近幾年,資訊技術的得了快速發展,互聯網在逐漸普及,其在人們生活和生產中都得到了廣泛應用,并且取得了不錯的應用效果。計算機網路資訊在電力系統中的應用,一方面使電力系統的運行 ......

    uj5u.com 2020-09-10 02:01:03 more
  • 【CTF】CTFHub 技能樹 彩蛋 writeup

    ?碎碎念 CTFHub:https://www.ctfhub.com/ 筆者入門CTF時時剛開始刷的是bugku的舊平臺,后來才有了CTFHub。 感覺不論是網頁UI設計,還是題目質量,賽事跟蹤,工具軟體都做得很不錯。 而且因為獨到的金幣制度的確讓人有一種想去刷題賺金幣的感覺。 個人還是非常喜歡這個 ......

    uj5u.com 2020-09-10 02:04:05 more
  • 02windows基礎操作

    我學到了一下幾點 Windows系統目錄結構與滲透的作用 常見Windows的服務詳解 Windows埠詳解 常用的Windows注冊表詳解 hacker DOS命令詳解(net user / type /md /rd/ dir /cd /net use copy、批處理 等) 利用dos命令制作 ......

    uj5u.com 2020-09-10 02:04:18 more
  • 03.Linux基礎操作

    我學到了以下幾點 01Linux系統介紹02系統安裝,密碼啊破解03Linux常用命令04LAMP 01LINUX windows: win03 8 12 16 19 配置不繁瑣 Linux:redhat,centos(紅帽社區版),Ubuntu server,suse unix:金融機構,證券,銀 ......

    uj5u.com 2020-09-10 02:04:30 more
  • 05HTML

    01HTML介紹 02頭部標簽講解03基礎標簽講解04表單標簽講解 HTML前段語言 js1.了解代碼2.根據代碼 懂得挖掘漏洞 (POST注入/XSS漏洞上傳)3.黑帽seo 白帽seo 客戶網站被黑帽植入劫持代碼如何處理4.熟悉html表單 <html><head><title>TDK標題,描述 ......

    uj5u.com 2020-09-10 02:04:36 more
最新发布
  • 2023年最新微信小程式抓包教程

    01 開門見山 隔一個月發一篇文章,不過分。 首先回顧一下《微信系結手機號資料庫被脫庫事件》,我也是第一時間得知了這個訊息,然后跟蹤了整件事情的經過。下面是這起事件的相關截圖以及近日流出的一萬條資料樣本: 個人認為這件事也沒什么,還不如關注一下之前45億快遞資料查詢渠道疑似在近日復活的訊息。 訊息是 ......

    uj5u.com 2023-04-20 08:48:24 more
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:47:46 more
  • vulnhub_Earth

    前言 靶機地址->>>vulnhub_Earth 攻擊機ip:192.168.20.121 靶機ip:192.168.20.122 參考文章 https://www.cnblogs.com/Jing-X/archive/2022/04/03/16097695.html https://www.cnb ......

    uj5u.com 2023-04-20 07:46:20 more
  • 從4k到42k,軟體測驗工程師的漲薪史,給我看哭了

    清明節一過,盲猜大家已經無心上班,在數著日子準備過五一,但一想到銀行卡里的余額……瞬間心情就不美麗了。最近,2023年高校畢業生就業調查顯示,本科畢業月平均起薪為5825元。調查一出,便有很多同學表示自己又被平均了。看著這一資料,不免讓人想到前不久中國青年報的一項調查:近六成大學生認為畢業10年內會 ......

    uj5u.com 2023-04-20 07:44:00 more
  • 最新版本 Stable Diffusion 開源 AI 繪畫工具之中文自動提詞篇

    🎈 標簽生成器 由于輸入正向提示詞 prompt 和反向提示詞 negative prompt 都是使用英文,所以對學習母語的我們非常不友好 使用網址:https://tinygeeker.github.io/p/ai-prompt-generator 這個網址是為了讓大家在使用 AI 繪畫的時候 ......

    uj5u.com 2023-04-20 07:43:36 more
  • 漫談前端自動化測驗演進之路及測驗工具分析

    隨著前端技術的不斷發展和應用程式的日益復雜,前端自動化測驗也在不斷演進。隨著 Web 應用程式變得越來越復雜,自動化測驗的需求也越來越高。如今,自動化測驗已經成為 Web 應用程式開發程序中不可或缺的一部分,它們可以幫助開發人員更快地發現和修復錯誤,提高應用程式的性能和可靠性。 ......

    uj5u.com 2023-04-20 07:43:16 more
  • CANN開發實踐:4個DVPP記憶體問題的典型案例解讀

    摘要:由于DVPP媒體資料處理功能對存放輸入、輸出資料的記憶體有更高的要求(例如,記憶體首地址128位元組對齊),因此需呼叫專用的記憶體申請介面,那么本期就分享幾個關于DVPP記憶體問題的典型案例,并給出原因分析及解決方法。 本文分享自華為云社區《FAQ_DVPP記憶體問題案例》,作者:昇騰CANN。 DVPP ......

    uj5u.com 2023-04-20 07:43:03 more
  • msf學習

    msf學習 以kali自帶的msf為例 一、msf核心模塊與功能 msf模塊都放在/usr/share/metasploit-framework/modules目錄下 1、auxiliary 輔助模塊,輔助滲透(埠掃描、登錄密碼爆破、漏洞驗證等) 2、encoders 編碼器模塊,主要包含各種編碼 ......

    uj5u.com 2023-04-20 07:42:59 more
  • Halcon軟體安裝與界面簡介

    1. 下載Halcon17版本到到本地 2. 雙擊安裝包后 3. 步驟如下 1.2 Halcon軟體安裝 界面分為四大塊 1. Halcon的五個助手 1) 影像采集助手:與相機連接,設定相機引數,采集影像 2) 標定助手:九點標定或是其它的標定,生成標定檔案及內參外參,可以將像素單位轉換為長度單位 ......

    uj5u.com 2023-04-20 07:42:17 more
  • 在MacOS下使用Unity3D開發游戲

    第一次發博客,先發一下我的游戲開發環境吧。 去年2月份買了一臺MacBookPro2021 M1pro(以下簡稱mbp),這一年來一直在用mbp開發游戲。我大致分享一下我的開發工具以及使用體驗。 1、Unity 官網鏈接: https://unity.cn/releases 我一般使用的Apple ......

    uj5u.com 2023-04-20 07:40:19 more