#!/bin/sh
#要求用户输入数值,然后打印出该数值,直到用户输入"end"后才停止
#vi show_var.sh
unset var
echo "please input a number:"
read var
while["$var" != "end"]
do
echo "please input a number again:"
read var
if["$var" = "end"]
then
break
fi
echo "var is : $var"
done
shell ksh
------解决方案--------------------------------------------------------
while["$var" != "end"]和if["$var" = "end"]
请用空格将每个单元隔开!
while [ "$var" != "end" ]
if [ "$var" = "end ]
------解决方案--------------------------------------------------------
#!/bin/ksh
#要求用户输入数值,然后打印出该数值,直到用户输入"end"后才停止
#vi show_var.sh
unset var
echo "please input a number:"
read var
while[ "$var" != "end" ]
do
echo "please input a number again:"
read var
if[ "$var" = "end" ]
then
break
fi
echo "var is : $var"
done