首页 > 系统服务 > 详细

shell计算脚本

时间:2018-07-28 18:53:12      阅读:153      评论:0      收藏:0      [点我收藏+]
#!/bin/bash
print_usage () {
printf "please enter an inteper \n"
}
read -p "Please input first number:" firstnum
while [ "echo "$firstnum" | sed -r ‘s#[^0-9]##g‘" != "$firstnum" ]
do
print_usage
read firstnum
done
read -p "Please input the operators:" operators
while [ "$operators" != "+" ]&&[ "$operators" != "-" ]&&[ "$operators" != "" ]&&[ "$operators" != "/" ]
do
read -p "please use + -
/" operators
done
read -p "Please input second number:" secondnum
while [ "echo "$secondnum" | sed -r ‘s#[^0-9]##g‘" != "$secondnum" ]
do
print_usage
read secondnum
done
echo "${firstnum}${operators}${secondnum} =$((${firstnum}${operators}${secondnum}))"
echo "$$" >/var/run/jsq.pid

shell计算脚本

原文:http://blog.51cto.com/13588698/2151522

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!