case can also be used for matching multiple patterns.

Ngoc Hue

New member
case can also be used for matching multiple patterns.
A. True
B. False
 
Answer: a
Explanation: case statement can also specify the same action for more than one pattern. Suppose, a programmer wants to develop a logic for both Y or y (or N or n), then he/she can make use of the case statement in the following manner:
Code:
echo “do you wish to continue? (y/n) : ”
read answer
case  “$answer” in
    y|Y) ;;            //NULL statement, no action to be performed 
    n|N) exit ;;
 

Tìm kiếm

Back
Top