#! /Bin/basffe [$ #-EQ 0]; then Echo "the input value cannot be blank." // The system prompts that null values cannot be entered. Note: $ # indicates the number of environment variables exitfinum =* * // defines a global variable to facilitate the subsequent call of sum () {sum = 0 while [$ #-GT 0] Do sum = $ [$ sum + $1] shiftdoneecho "the sum of the number $ num is $ sum"} Cha () {CHA = $1 shiftwhile [$ #-GT 0] Do CHA = $ [$ cha-$1] shiftdoneecho "number $ num minus $ cha"} Cheng () {Cheng = $1 shiftwhile [$ #-GT 0] Do Cheng = $ [$ Cheng * $1] shiftdoneecho "The number $ num is multiplied by $ Cheng"} Chu () {Chu = $1 shiftwhile [$ #-GT 0] Do Chu = $ [$ Chu/$1] shiftdoneecho "number $ num division operator is $ chu"} Read-P "Enter + |-| * | /: "typecase" $ type "in" + ") sum $ *;"-") Cha $ *;" * ") Cheng $ *;;"/") chu $ *; *) echo "Enter {+ |-| * |/}" esac
Shell scripts calculate any number of addition, subtraction, multiplication, division