#!/bin/bashecho"Enter your lucky number"read n
case$nin
101)echo echo"You got 1st prize";;
510)echo"You got 2nd prize";;
999)echo"You got 3rd prize";;*)echo"Sorry, try for the next time";;esac
예제.2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bashecho"What is your preferred programming / scripting language"echo"1) bash"echo"2) perl"echo"3) phyton"echo"4) c++"echo"5) I do not know !"read case;# simple case bash structure# note in this case $case is variable and does not have to# be named case this is just an examplecase$casein
1)echo"You selected bash";;
2)echo"You selected perl";;
3)echo"You selected phyton";;
4)echo"You selected c++";;
5)exit
esac
#!/bin/bashecho"1) kim"echo"2) lee"echo"3) park"echo-n"select your first name ? :"read name
case$namein
1)echo" your first name is kim";;
2)echo" your first name is lee";;*)echo" your first name is park";;esac
예제.5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/shecho"리눅스가 재미있나요?(Yes / no)"read answer
case$answerin
yes|y|Y|Yes|YES)echo"다행입니다."echo"더욱 열심히 하세요^^";;[nN]*)echo"안타깝네요.ㅠㅠ";;*)echo"yes 아니면 no 만 입력했어야죠"exit 1;;esacexit 0