码迷,mamicode.com
首页 > 系统相关 > 详细

linux operators

时间:2018-01-10 11:23:48      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:ash   send   put   opera   int   second   amp   echo   ber   

#! /bin/bash
print_usage(){
printf "please enter an integer\n"
exit 5
}

read -p "please input first number: " firstnum
if [ -n "echo $firstnum | sed ‘s/[0-9]//g‘" ];then
print_usage
fi

read -p "please input operators: " operators
if [ "${operators}" != "+" ] && [ "${operators}" != "-" ] && [ "${operators}" != "" ] && [ "${operators}" != "/" ];then
echo "please input {+|-|
|/}"
exit 10
fi

read -p "please input send number: " secondnum
if [ -n "echo $secondnum | sed ‘s/[0-9]//g‘" ];then
print_usage
fi
echo "${firstnum}${operators}${secondnum}=$((${firstnum}${operators}${secondnum}))"

linux operators

标签:ash   send   put   opera   int   second   amp   echo   ber   

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

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