Shell Programming Basics of Select Exercise

Source: Internet
Author: User

First, the grammar
Select inch con1 con2 con3    # automatically lists Con1,con2,con3 's selection menu do     #执行内容break    # Select itself is a loop, Break is when you choose to jump out of the loop done 
Second, practice
  1. Select + Case Emulation Linux startup script
    functionProgramstatus () {if[" $"-eq0]; Then    Echo "* Program is running"  Else    Echo "* program has stopped"  fi}status=0#0: Start;1: StopSelectPinch "Start" "Stop" "Status" "Restart" "*" "" Do Case "$p" inch"Start") Status=0programstatus $status;;"Stop") Status=1programstatus $status;;"Status") programstatus $status;;"Restart")  if["$status"-eq0]; ThenStatus=1    Echo "* program has stopped"  fiStatus=0  Echo "* Program is running"  ;;"") break;;*)  Echo "Plz input [Start|stop|status|restart]"   ;;Esac Done
     [email protected]:~$./test. sh  1  ) start  2  ) stop  3   Status  4  ) restart  5  ) # ? 1  * program is running# ? 2  * program has stopped# ? 3  * program has stopped# ? 4  * program is running# ? 5  [email protected]:  ~$ 

Shell Programming Basics of Select Exercise

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.