学习型 ASP/PHP/ASP.NET 主机 30元/年全能 ASP/PHP/ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付
发新话题
打印

Shell程序设计(学习贴)

本主题由 静夜思 于 2008-4-15 12:37 拒绝承认原创

Shell程序设计(学习贴)

#! /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

TOP

发新话题