2006-12-14 14:51
tozjq
shell脚本下,怎么比较变量?
more test.sh:
c1=1
c2=10
while ($c1 -le $c2)
do
echo $c1
c1=$(($c1+1))
done
这样写对吗?
2006-12-18 20:22
windguy
sh下面不是这样比较的!
#!/bin/sh
c1=1
c2=10
while :
do
echo $c1
c1=`expr $c1 + 1 `
if test $c1 -gt $c2
then
exit 1
fi
done
你是想打出 1~10 吧。上面是一个一直为true的循环,在if里面判断是不是大于10,比10大则退出。
2007-1-4 11:05
xiaophedap
more test.sh:
c1=1
c2=10
while [ $c1 -le $c2 ]
do
echo $c1
c1=$(($c1+1))
done
2007-7-21 21:46
xier0521
#!/bin/sh
#test.sh
#defiin the argumeints
c1=1
c2=10
while :
do
echo $c1
c1=`expr $c1 + 1 `
if [ $c1 -gt $c2 ]
then
exit 1
fi
done
页:
[1]
Powered by Discuz! Archiver 5.5.0
© 2001-2006 Comsenz Inc.