displayplatformmenu() {
#clear the screen
clear
displayheader
echo " a) SunSparc "
echo " b) IntelPentium "
echo " c) AMD "
echo " d) Unicore32 "
echo " e) Unicore32(with FP2001) "
echo " "
echo -n " select a Platform > "
}
#接收一个菜单输入
displayplatformmenu
read answer
case ${answer} in
a) TARGET="BasicOp";;
b) TARGET="Conversion";;
*) badchoice;;
esac
#查找当前目录下是否存在file_name文件
#可以用来作为if用法的参考
detectfile_name() {
if [ ! -f file_name ]
then
echo "Error: file_name does not exist. Please check"
exit 1;
else
echo "OK,the directy is exist"
fi
}
#将参数指定的一个或多个目录项以及其下的多级子目录下的所有文件名和目录名转换为小写。
cvitem()
{
echo "mv $1 `dirname $1`/`basename $1 | tr
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`"
}
[ $# = 0 ] && { echo "Usage: lcdir item1 item2 ..."; exit; }
for item in $* #可以用来作为for用法的参考
do
[ "`dirname $item`" != "`basename $item`" ] && {
[ -d $item ] &&
{
for subitem in `ls $item`
do
cvlc $item/$subitem
done
}
cvitem $item
}
done
#一个login的例子
if ($?path) then
set path=($HOME/bin $path)
else
set path=($HOME/bin /usr/bin .)
endif
if ( ! $ {?DT} ); then
stty dec new
tset -I -Q
endif
set mail=/usr/spool/mail/$USER
#关于if使用的几个例子
#执行一个命令或程序之前,先检查该命令是否存在,然後才执行
if [ -x /sbin/quotaon ] ; then
echo "Turning on Quota for root filesystem"
/sbin/quotaon /
fi
#得到Hostname
#!/bin/sh
if [ -f /etc/HOSTNAME ] ; then
HOSTNAME=`cat /etc/HOSTNAME`
else
HOSTNAME=localhost
fi
#如果某个设定档允许有好几个位置的话,例如crontab,可利用if then elif fi来找寻
if [ -f /etc/crontab ] ; then #[ -f /etc/crontab ]等价于test -f /etc/crontab
CRONTAB="/etc/crontab"
elif [ -f /var/spool/cron/crontabs/root ] ; then
CRONTAB="/var/spool/cron/crontabs/root"
elif [ -f /var/cron/tabs/root ] ; then
CRONTAB="/var/cron/tabs/root"
fi
export CRONTAB
#利用uname来判断目前系统,并分别做各系统状况不同的事。










