当前位置: 技术问答>linux和unix
我的第一个shell,不知道问题是哪~?!
来源: 互联网 发布时间:2016-03-15
本文导语: if test $#=3 then case $2 in +) let z=$1+$3;; -) let z=$1-$3;; *) let z=$1*$3;; /) let z=$1/$3;; *) echo "$2 invalied operator" exit;; esac echo "An...
if test $#=3
then
case $2 in
+) let z=$1+$3;;
-) let z=$1-$3;;
*) let z=$1*$3;;
/) let z=$1/$3;;
*) echo "$2 invalied operator"
exit;;
esac
echo "Answer is $z"
else
echo "Usage : -$0 valuel operator values2"
fi
谢谢有心人哦
then
case $2 in
+) let z=$1+$3;;
-) let z=$1-$3;;
*) let z=$1*$3;;
/) let z=$1/$3;;
*) echo "$2 invalied operator"
exit;;
esac
echo "Answer is $z"
else
echo "Usage : -$0 valuel operator values2"
fi
谢谢有心人哦
|
if [ "$#" -eq "3" ]
then
case $2 in
+) echo +;;
-) echo -;;
*) echo *;;
/) echo /;;
*)echo "$2 invalied operator"
exit;
esac
else
echo "Usage : -$0 valuel operator values2";
fi