课程: Linux: Bash Shell and Scripts
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Control-flow case statements and if-then-else with the test command - Linux教程
课程: Linux: Bash Shell and Scripts
Control-flow case statements and if-then-else with the test command
- [Teacher] The Case Statement is used in a Bash script to compare an expression to a sequence of patterns. The expression might be value of a variable. The patterns are file glob kinda patterns, not regular expressions, and they're checked in sequence. So here, we look at the value of the variable ans, or answer, and we'd first compare it to all-lowercase yes or all-uppercase YES, or just the little y or just the big Y, or y.x. So if ans matches any of those patterns, then we're gonna print out "Will do!" The semicolon semicolon right next to each other with no spaces there is a special Case Statement thing of saying, "This is the end of the statements "we're gonna do for this pattern." Now y.x looks like maybe kind of a special regular expression sorta thing, but in file-globbing, dot means dot, it doesn't mean a special character. So we'd actually have to type in y dot x, not yax or ybx or something like that. y dot x, that's not really special. The second pattern we have, n star…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
(已锁定)
The typeset and declare commands for variables5 分钟 7 秒
-
(已锁定)
Looping with for/while sequences and reading input14 分钟 20 秒
-
(已锁定)
Defining functions and using return and exit6 分钟 29 秒
-
(已锁定)
Using file descriptors, file redirection, pipes, and here documents16 分钟 52 秒
-
(已锁定)
Control-flow case statements and if-then-else with the test command10 分钟 11 秒
-
(已锁定)
Using arithmetic operators2 分钟 27 秒
-
(已锁定)
Challenges: Using local variables in functions, loops, and arithmetic2 分钟 44 秒
-
(已锁定)
Solutions: Using local variables in functions, loops, and arithmetic4 分钟 2 秒
-
(已锁定)
-
-
-