文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Embedded Training Content --Bash Programming

Embedded Training Content --Bash Programming

时间:2009-08-08  来源:creatory

#!/bin/sh
if [ $# -eq 0 ];then
    echo "Usage:$0 <filenamelist>"
else
    if  test -f $1 ;then
        echo "File exists!"
    else
        echo "File not exists"
    fi
fi

#!/bin/bash
echo "input score:"
read score
if [ $score -ge 90 ];then
    echo "Best"
else
    if [ $score -ge 80 ];then
        echo "Better"
    else
        if [ $score -ge 70 ]; then
            echo "Good"
        else
            if [ $score -ge 60 ];then
                echo "Normal"
            else
                echo "Work Harder"
            fi
        fi
    fi
fi

#!/bin/sh
echo "input score:"
read score
if [ $score -gt 100 ]
then
    echo "Great Than 100.Input Again!"
elif test $score -ge 90 ; then
    echo "best"
elif test $score -ge 80; then
    echo "better"
elif test $score -ge 70; then
    echo "good"
elif test $score -ge 60; then
    echo "normal"
else
    echo "work harder"
fi

#!/bin/sh
echo -n "Input(1-9):"
read num
case $num in
"1")
    ret="one";;
"2")
    ret="two";;
"3")    
    ret="three";;
"4")
    ret="four";;
*)
    ret="error";;
esac
echo $num=$ret

#!/bin/sh
echo -n "login name:"
read name
if test -z $name ;then
    echo "no input"
else
    if test $name != "creatory";then
        echo "no this user"
    else
        echo "login name ok"
    fi
fi

#!/bin/bash
i=1
while [ $i -le 9 ]
    do
        echo $i^3=`expr $i \* $i \* $i`
        i=`expr $i + 1`   
    done

#!/bin/sh
i=1
until [ $i -ge 10 ]
    do
        echo $i^3=`expr $i \* $i \* $i`
        i=`expr $i + 1`
    done

#!/bin/bash
for x in a b c d
    do
        echo $x
    done

for x in a,b,c,d
    do
        echo $x
    done

#!/bin/bash
while test 1
do
    clear
    echo "Give your selection:"
    echo -n "1:date 2:who "
    echo "3:ls 4:pwd"
    echo "q:exit"
    read select
    case $select in
    "1")
        date;;
    "2")
        who;;
    "3")
        ls;;
    "4")
        pwd;;
    "q")
        break;;
    *)
        echo "input error,retry!";;
    esac
    sleep 5
done

author:[email protected]
modify time:08/08/2009 training time:08/03/2008 Monday
place:ZPark,Beijing,China
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载