当前位置: 技术问答>linux和unix
很简单的脚本程序,总是报错
来源: 互联网 发布时间:2015-07-01
本文导语: 下面的脚本程序,总是报错,不知是什么原因 loopcount=0 result=0 while [ $loopcount -lt 10 ] do loopcount=`expr $loopcount + 1' result='$result + ($loopcount*2) ` done echo "result is $resul 还有另一个是,也总是报...
下面的脚本程序,总是报错,不知是什么原因
loopcount=0
result=0
while [ $loopcount -lt 10 ]
do
loopcount=`expr $loopcount + 1'
result='$result + ($loopcount*2) `
done
echo "result is $resul
还有另一个是,也总是报错
for filename in `ls`
do
cp $filename backup/$filename
if [ $? - ne 0 ]
echo " copy $filename failed "
fi
done
多谢
loopcount=0
result=0
while [ $loopcount -lt 10 ]
do
loopcount=`expr $loopcount + 1'
result='$result + ($loopcount*2) `
done
echo "result is $resul
还有另一个是,也总是报错
for filename in `ls`
do
cp $filename backup/$filename
if [ $? - ne 0 ]
echo " copy $filename failed "
fi
done
多谢
|
第一个,result=那句没加expr
第二个,if没加then
第二个,if没加then
|
#!/bin/bash
loopcount=0
result=0
while [ $loopcount -lt 10 ]
do
loopcount=$[ $loopcount + 1 ]
result=$[ $result + ( $loopcount * 2 ) ]
done
echo "result is" $result
loopcount=0
result=0
while [ $loopcount -lt 10 ]
do
loopcount=$[ $loopcount + 1 ]
result=$[ $result + ( $loopcount * 2 ) ]
done
echo "result is" $result
|
#!/bin/sh
loopcount=0
result=0
while [ $loopcount -lt 10 ]
do
loopcount=`expr $loopcount + 1`
result=`expr $result + $loopcount * 2`
done
echo "result is $result"
loopcount=0
result=0
while [ $loopcount -lt 10 ]
do
loopcount=`expr $loopcount + 1`
result=`expr $result + $loopcount * 2`
done
echo "result is $result"
|
注意:要将*写成*