Listing 30. Example of a case statement in bash.
清单30. bash中的case语句示例。
Listing 7 extends this case statement to handle delayed_job roles.
清单7扩展了这个case语句,来处理delayed_job角色。
A case statement within bash lets you test for more than one condition or value and act accordingly.
bash中的case语句可以用来测试多个条件或值并相应地执行操作。
The case statement is another conditional statement that you can use in place of using an if statement.
case语句是另一种条件型语句,您可以用该语句来替代if 语句。
Listing 1 shows an example of an SQL procedure with a case statement with a simple-case-statement-when-clause.
清单1展示了一个SQL过程的示例,包含一个case语句和一个simple - case - statement - when - clause。
A case statement allows you to quickly build upon it as your script evolves and needs to perform different tasks.
当您的脚本变得比较复杂、并且需要执行不同的任务时,可以使用case语句迅速地进行构建。
So, each time this section of code is executed, the $TIME is checked to see if it matches the times of the case statement.
因此,每次执行这个代码段的时候,将检查 $TIME是否匹配case语句所指定的时间。
For each option, the case statement then attempts to identify the option, using either the short or long format and setting a variable.
对于每个选项,case语句会尝试识别该选项——使用短格式或长格式并设置一个变量。
Although it isn't the optimal solution, multiple elif statements can be used to mimic the switch case statement present in some other languages.
尽管它不是最优的解决方案,但是多个elif语句可以用于模拟其他一些语言中的switchcase语句。
Consider the code above and realize that any enumerated value not specifically processed by a case statement is instead processed by the default statement.
研究以上代码可以看出,任何没有被case语句处理的枚举值都会被default语句处理。
The getopts command returns true if an option is found, so a common option processing paradigm uses a while loop with a case statement as in this example.
如果找到一个选项,则getopts命令返回true,因此常见的选项处理范例使用带case语句的while 循环,本例中就是如此。
For example, you can use it in combination with a case statement to choose the right aliases, as per the ps examples in the previous section, like Listing 10.
例如,可以按照前一部分中的ps示例,将该命令与case语句结合使用以选择正确的别名,如清单10所示。
The case statement works like its counterparts in traditional programming languages: It compares its argument to each pattern in a list; when a match is found, the corresponding code executes.
case语句的工作方式与传统编程语言中的对应结构相似。它将其参数与列表中的每个模式比较;当找到匹配项时,则执行对应的代码。
Now, this means that one can use a Proc object in a case-statement; it will get the case-argument as parameter.
现在,这意味着可以在case语句中使用Proc对象了;可以将case参数作为Proc的参数。
Now, this means that one can use a Proc object in a case-statement; it will get the case-argument as parameter.
现在,这意味着可以在case语句中使用Proc对象了;可以将case参数作为Proc的参数。
应用推荐