"2")
myprint;echo "TWO"
"3")
myprint;echo "THREE"
esac
exit 0
调用:
$ bash sh09.sh
Tell me your choice:[1-3]=>1
Your choice is ONE
$ bash sh09.sh
Tell me your choice:[1-3]=>2
Your choice is TWO
$ bash sh09.sh
Tell me your choice:[1-3]=>3
Your choice is THREE
7 循环
7.1 while
# !/bin/bash
# Program:
# This program shows while expression
# History:
# 2013/2/3 on_1y First release
PATH=$PATH
export PATH
while [ "$choice" != "yes" ]
do
read -p "Give your choice [yes/no]:" choice
done
exit 0
调用:
$ bash sh10.sh
Give your choice [yes/no]:no
Give your choice [yes/no]:no
Give your choice [yes/no]:nx
Give your choice [yes/no]:yes
7.2 for
# !/bin/bash
# Program:
# This program is used to demo for expression
# History:
# 2013/2/3 on_1y First release
PATH=$PATH
export PATH
for choice in 1 2 3
do
echo "your choice is $choice"
done
exit 0
调用示例:
$ bash sh11.sh
your choice is 1
your choice is 2
your choice is 3
8 shell script的追踪与Debug
sh -n xx.sh # 语法检查
sh -x xx.sh # 列出xx.sh的执行过程










