Shell Programming Basics Case Exercise

Source: Internet
Author: User

First, the grammar
 Case  inch  " content of the first variable "    # Each variable content is suggested in double quotation marks, the keyword is parentheses)    # execution content    ;;              # Use two consecutive semicolons to handle each category end!   " content of the second variable " )    # execution content    ;;   *)                # The last variable content will use * to represent all other values, but does not contain the contents of the first variable with the second variable contents of the other program run segment    # execution content    ;; Esac                 Case
Second, practice
  1. Simulating Linux startup scripts
    status=0#0: Start;1: Stop Case " $" inch"Start")    Echo "* Program is running"  ;;"Stop")    Echo "* Stopping program"  ;;"Status")    Echo "* Program is running"  ;;"Restart")    Echo "* Stopping program"    Echo "* Program is running"  ;;*)    Echo "Plz input [Start|stop|status|restart]"   ;;Esac
    [Email protected]:~$./test. SH Start* program is running[email protected]:~$./test. SH Stop* stopping  program[email protected]:~$./test.  SH  Status* program is running[email protected]:~$./test. SH Restart* stoppingprogram * is running[email protected]:~$./test. SH Plz input [start|stop|status| Restart] [Email protected]:~$

Case exercises based on Shell programming

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.