This article was reproduced from: http://c.biancheng.net/cpp/view/7006.htmlC Language Chinese network launched remedial classes, including "c language tutorial, C + + tutorial, algorithm/Data Structure Tutorial", all are one-to-one teaching: a
Case ... Esac is similar to the switch ... case statement in other languages, and is a multi-branch selection structure.The case statement matches a value or a pattern, and if the match succeeds, the matching command is executed. The case statement
#case: ESAC statement: with switch. Case similar, is a multi-branch selection structure#case语句匹配一个值或一个模式 if the match succeeds in executing the corresponding command, if the match does not execute the * command successfully#;; Similar to break, the
1. case... in... esac
The syntax of case... in... esac is as follows:Case $ variable name in"First variable content ")Program Section;;"Second variable content ")Program Section;;*)Other Program Execution segments that do not contain the first
Conditional judgment----Use case ... ESAC judgmentCase $ variable name in "First variable content") Program Segment;; "Second variable content")Program Segment;;*) Other program execution segments that do not contain the contents of the first
Case $ variable name in
"First variable content ")
ProgramSegment
;;
"Second variable content ")
Program Section
;
*)
Other program segments that do not contain the first variable content or the second variable content
Exit 1
;;
Case ... Esac is similar to the switch ... case statement in other languages, and is a multi-branch selection structure.The case statement matches a value or a pattern, and if the match succeeds, the matching command is executed. The case statement
Case ... Esac is similar to the switch ... case statement in other languages, and is a multi-branch selection structure.The case statement matches a value or a pattern, and if the match succeeds, the matching command is executed. The case statement
Case ... Esac is similar to the switch ... case statement in other languages, and is a multi-branch selection structure.The case statement matches a value or a pattern, and if the match succeeds, the matching command is executed. The case statement
1, the use of CASE...ESAC#!/bin/Bashecho"Please enter a number to choose a different way to display files and directories:"Echo"1-Normal display"Echo"2-Detailed display"Echo"3-Show hidden files"Echo"4-Exit"Read NUM1 Case$num 1inch 1) LS;; 2)
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.