编程论坛's Archiver

guixiaolan 发表于 2008-4-14 17:26

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

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.