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

shell计算脚本

时间:2018-07-28 18:56:16      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:计算   脚本   first   please   \n   enter   sed   code   inpu   

#!/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计算脚本

标签:计算   脚本   first   please   \n   enter   sed   code   inpu   

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

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