首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

linux上shell编程实例

2012-09-20 
linux下shell编程实例echo A is: echo $a num2 echo this is the ${num}nd # this is a test times0

linux下shell编程实例
echo "A is:"
echo $a

num=2
echo "this is the ${num}nd"



# this is a test

times=0
until ["$times"=3];
do
echo "I love linux."
sleep 2
times=`expr $times+1`
done


?

fi

# test for
for((i=1;i<10;i++))
do
res=`expr $i \* $i`
echo $res
done


# test while
num=1
while [ $num -le 10 ]
do
sum=`expr $num \* $num`
echo $sum
num=`expr $num + 1`
done





echo -n "Enter Choice:"

read choice

case "$choice" in
1) echo "Restore";;
2) echo "Backup";;
3) echo "Unload";;
*) echo "Sorry $choice is not a valid choice"
exit 1
esac

?

elif [ -d $i ]
then
echo "$i is a directory"
fi
done

?

?

热点排行