#!/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
原文地址:http://blog.51cto.com/13588698/2151522
时间: 2024-10-10 19:54:40