码迷,mamicode.com
首页 > 其他好文 > 详细

operators usages

时间:2018-01-11 11:24:14      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:arguments   amp   exp   argument   nts   tor   dev   $#   put   

#! /bin/bash
if [ $# -ne 2 ];then
echo "please input two arguments:"
exit 2
fi
expr $1 + 2 &>/dev/null
if [ $? -ne 0 ];then
echo "please input int."
exit 3
fi
expr $2 + 3 &>/dev/null
if [ $? -ne 0 ];then
echo "please input int."
exit 4
fi

echo "$1+$2 is $(($1+$2))"
echo "$1$2 is $(($1$2))"
echo "$1-$2 is $(($1-$2))"
echo "$1/$2 is $(($1/$2))"

operators usages

标签:arguments   amp   exp   argument   nts   tor   dev   $#   put   

原文地址:http://blog.51cto.com/546136/2059684

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!