Linux系统

shell脚本基本经典程序

时间:2013-9-11 13:39:51  作者:说歌社区  来源:www.solgle.com  查看:196  评论:0
内容摘要:#using if and then to select file or directoryif [ ! -e logical ]; then 琀漀甀挀栀 logical 攀挀栀漀 "Just make a file logical" 攀砀椀琀 1elif [ ...
#using if and then to select file or directory
if [ ! -e logical ]; then
    touch logical
    echo "Just make a file logical"
    exit 1
elif [ -e logical ] && [ -f logical ]; then
    rm logical
    mkdir logical
    echo "remove file ==> logical"
    echo "and make directory logical"
    exit 1
elif [ -e logical ] && [ -d logical ]; then
    rm -rf logical
    echo "remove directory ==> logical"
    exit 1
else
    echo "Does here have anythings?"
fi


#using until do done
echo "Press Y/y to stop"
until [ "$yn" = "Y" ] || [ "$yn" = "y" ]
do
    read yn
done
echo "stop here"


#using for do done
LIST="tomy jony mary Geoge"
for i in $LIST
do
    echo $i
done


#using case mode
echo "Press your select one,two,three"
read number
case $number in
    one)
        echo "your choice is one"
        ;;
    two)
        echo "your choice is two"
        ;;
    three)
        echo "your choice is three"
        ;;
    *)
        echo "Usage (one|two|three)"
        exit 1
esac


#uting while and loop
declare -i i
declare -i s
while [ "$i" != "101" ]
do
    s=s+i
    i=i+1
done
echo "The count is ==> $s"




标签:shell脚本基本经典程序 

solgle.com 版权所有,欢迎分享!!!

相关文章
    相关评论
       Copyright © 2013-2020 solgle.com,All rights reserved.[solgle.com] 公安机关备案号:51010802000219
    Email:solgle@solgle.com; weixin:cd1008610000 ICP:蜀ICP备14011070号-1