case expression in pattern-1) statement ;; pattern-2) statement ;; . . . pattern-N) statement ;; *) statement ;; esac 一个case语句必须与开始case的关键字和结束与esac关键字。表达式被评估并与每个子句中的模式进行比较, 直到找到匹配项。匹配子句中的一...
The case statement uses the Extension variable as the expression it tries to match to a clause. #!/bin/bash forFilein$(ls) do # extract the file extension Extension=${File##*.} case"$Extension"in sh) echo" Shell script:$File" ;; md) echo" Markdown file:$File" ;; png) echo"PN...
We have discussed already what a switch case, its syntax is. Now, we will see in detail how it will work in shell scripting. Initially, we initialize a variable with an expression or value and conditional statement checks whether it satisfies any condition, if yes then it will execute the ...
case expression in pattern-1) statement ;; pattern-2) statement ;; . . . pattern-N) statement ;; *) statement ;; esac 一个case语句必须与开始case的关键字和结束与esac关键字。 表达式被评估并与每个子句中的模式进行比较, 直到找到匹配项。 匹配子句中的一个或多个语句被执行。 双分号“;;”用于...
This tutorial will cover the basics of the Bash case statement and show you how to use it in your shell scripts. case Statement Syntax The syntax of the Bash case statement consists of the “case” keyword followed by the value to be matched, the “in” keyword, and one or more ...
Example of a BASH Script with the CASE Statement #!/bin/bash printf 'Which Linux distribution do you know? ' read DISTR case $DISTR in ubuntu) echo "I know it! It is an operating system based on Debian." ;; centos|rhel) echo "Hey! It is my favorite Server OS!" ...
Shell case esac 语句case ... esac 与其他语言中的 switch ... case 语句类似,是一种多分枝选择结构。case 语句匹配一个值或一个模式,如果匹配成功,执行相匹配的命令。case 语句格式如下:case 值in 模式1) command1 command2 command3 ;; 模式2) command1 command2 command3 ;; *) command1 command2 ...
2. 'in that case' You say in that case or in which case to refer to a situation which has just been mentioned and to introduce a statement or suggestion that is a consequence of it. 'The bar is closed,' the waiter said. 'In that case,' McFee said, 'allow me to invite you back...
shell逻辑控制语句之case,case分支判断结构语法:case变量名称invalue1)statementstatement;;value2)statementstatement;;value3)statementstatement;; *)statementstatement;;esac编写脚本,判断用户输入的
shell中的case语句与其他语言中的switch/case语句类似,是一种多分支选择结构 case $var in pattern1) Statement(s) to be executed when $var match pattern 1 ;; pattern2) Statement(s) to be executed when $var match pattern 3 ;; ...