-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCase_Statement.sh
44 lines (41 loc) · 939 Bytes
/
Case_Statement.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## Syntax for case statement
# case expression in
# pattern1 )
# statements1 ;;
# pattern2 )
# statements2 ;;
# patternN )
# statementsN ;;
# esac
echo -e "Enter some character: \c"
read color
case $color in ## Matching the color variable with the regex pattern
[A-Z])
echo "This is $color is of caps char."
;;
[a-z])
echo "This is $color is of small char."
;;
[0-9])
echo "This is $color is of int. "
;;
?)
echo "This is $color is of symbolic value. "
;;
*)
echo "This is $color which is unknown value. "
;;
esac
# color=$1
# case $color in
# "blue" )
# echo "This is $color is of 5 inr. " ;;
# "red" )
# echo "This is $color is of 15 inr. " ;;
# "green" )
# echo "This is $color is of 25 inr. " ;;
# "yellow" )
# echo "This is $color is of 35 inr. " ;;
# * )
# echo "This is $color which is unknown value. " ;;
# esac