shell計算腳本
阿新 • • 發佈:2018-07-28
use read printf second bin sage enter sed opera #!/bin/bash
print_usage () {
printf "please enter an inteper \n"
}
read -p "Please input first number:" firstnum
while [ "
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 [ "
do
print_usage
read secondnum
done
echo "${firstnum}${operators}${secondnum} =$((${firstnum}${operators}${secondnum}))"
echo "$$" >/var/run/jsq.pid
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" != "/" ]
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}))"
shell計算腳本