#!/bin/bash
echo -n "please input a select number:(1-3)"
read NO
case $NO in
1) echo "number 1 enter"
;;
2) echo "number 2 enter"
;;
3) echo "number 3 enter"
;;
*) echo "`basename $0`: not between 1-3">&2 //输出信息到标准错误
exit;
;;
esac
#!/bin/bash
echo "Is it moring? Please answer yes or no"
read timeofday
case "$timeofday" in
yes) echo "Good Morning";;
no ) echo "Good Afternoon";;
y ) echo "Good Morning";;
n ) echo "Good Afternoon";;
* ) echo "Sorry, answer not recognized";;
esac
exit 0
#!/bin/bash
echo "Is it moring? Please answer yes or no"
read timeofday
case "$timeofday" in
yes | y | Yes | YES ) echo "Good Morning";;
n* | N* ) echo "Good Afternoon";;
* ) echo "Sorry, answer not recognized";;
esac
exit 0
#!/bin/sh
function sayhw() {
echo "hello world"
}
function sayhl() {
echo "hello linux"
}
function sayhu() {
echo "hello unix"
}
echo "which do you want to?input the number."
echo "1. say hello world"
echo "2. say hello linux"
echo "3. say hello unix"
read num
case "$num" in
[1] ) (sayhw);;
[2] ) (sayhl);;
[3] ) (sayhu);;
*) echo "nothing,exit";;
esac
[beyes@beyes shell]$ sh case.sh
which do you want to?input the number.
1. say hello world
2. say hello linux
3. say hello unix
1
hello world
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |