linux实验4-bash1

#!/bin/bash
#set -xv
function welcome()
{
        echo "Use one of the following options:"
        echo "P: To display current directory"
        echo "S: To display the name of runing file"
        echo "D: To display today's date and present time"
        echo "L: To see the listing of files in your present working directory"
        echo "W: To see who is logged in"
        echo "Q: To quit this program"
        echo -n "Enter your option and hit:"
        read op
}
welcome
until [ 'expr match "$op" "[Q|q]"'=="0" ]; #注意空格
do
        case "$op" in
        P|p)
        pwd
        echo ""
        welcome
        ;;
        S|s)
        echo "The running file is $0"
        echo ""
        welcome
        ;;
        D|d)
        date
        echo ""
        welcome
        ;;
        L|l)
        ls -a
        echo ""
        welcome
        ;;
        W|w)
        who
        echo ""
        welcome
        ;;
        *)
        echo -n "Error!Please enter option again:"
        read op
        esac
done
echo "BYE"
exit 0


蛋疼的空格

posted @ 2013-11-04 21:56  Fresher_Z  阅读(126)  评论(0编辑  收藏  举报