Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Case Branch statement of shell programming

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The case branch statement of shell programming case branch statement is very similar to the multi-branch statement of if. If multi-branch statements are generally used where there is (interval range); for example, between 0 and 100. If needs to determine several different conditions. The branch statement of case is used if it matches to a fixed value, or if a variable has multiple values, you need to execute a different sequence of commands for each of these values. Case simply judges the different values of a variable. Mode of case:

Execution process: first use "variable value" to compare with mode 1, and if the value is the same, execute the command sequence 1 of mode 1 until you encounter ";;" and then jump to the end of esac. If it does not match mode 1, it continues to compare with the next mode 2, and if it is the same, execute the command sequence 2 of mode 2 until you meet ";" and jump to the end of esac. If no matching value is found, the default command sequence after the "*)" default mode is executed until the end of the esac encounter. When using case branch statements, there are several points to note: the 1.case line must end with the word 'in', every pattern must end with a closing parenthesis'. two。 The double semicolon ";" indicates the end of the command sequence. 3. In a pattern string, you can use "[]" to indicate a contiguous range, such as [0-9], or the vertical bar symbol "|" (or), such as: a | b. 4. The last ")", which represents the default mode, where "" is equivalent to a wildcard.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report