#!/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计算脚本
原创
©著作权归作者所有:来自51CTO博客作者数来宝的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:linux服务日常优化
下一篇:yum 源仓库的安装及配置
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
shell脚本阶乘计算
shell脚本上用户输入一个大于0的数并计算它的阶乘,当输入的数小于等于零时,就停止该脚本运行
的 计算 number written please -
shell脚本变量数值计算
shell脚本的变量数值计算
shell 数值计算