注册 登录
编程论坛 Linux教室

Shell程序设计(学习贴)

guixiaolan 发布于 2008-04-14 17:26, 1546 次点击
#! /bin/bash

if [ -f /etc/passwd ];then echo "file exists";fi
if((30>60||40<60));then echo "u r right";fi

for index in 1 2 3 4 5
do
    if [ $index -le 2 ];then
     echo "continue"
     continue
    elif [ $index -eq 5 ];then
     echo "break"
     break
    else
     echo "$index"
    fi
done

echo -n "enter a or b:"
read letter
case "$letter" in
    a|a) echo -e "you input a \023";;
    b|b) echo "you input b";;
    *) echo "you did not enter a or b";;
esac

ps3="plese choose:"
select fruit in apple banana stop
do
    if [ "$fruit" == "" ];then
     echo -e "invalid\n"
     continue
    elif [ "$fruit" == "stop" ];then
     echo "thanks for playing"
     break
    fi
echo "you choose $fruit"
echo -e "that number is $reply\n"
done
0 回复
1