Case commands in the shell

Source: Internet
Author: User
Tags case statement

The case statement and the judgment statement [If...elif...else] function similarly;
When logic is relatively simple, the code is much less than the latter.
Case usage, use a variable to match a value, if the match succeeds, execute the command below it until;; so far.

#!/bin/bash #a =20 #定义变量值case $a in         #若变量在下面的某值中, execute the command below    )         #值内容 can add |, can have multiple values {    echo "The A is"         #执行输出命令    echo "Over"         #执行输出命令};;         #注意这是两个; |30)         #值内容 can be added with |, there can be multiple values {    echo "The A is" #执行输出命令    echo "over" #执行输出命令};; *)         #默认匹配内容, if none of the above matches, execute this echo "Hello" #执行输出内容;; ESAC         #结束echo "test Case End"         

  

Case commands in the shell

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.