Fortune Telling Collection - Comprehensive fortune-telling - How to realize decimal addition, subtraction, multiplication and division with shell language

How to realize decimal addition, subtraction, multiplication and division with shell language

I originally wrote a calculator with a shell: [root @ lixitingtestdir] # catcalculator.sh #! /bin/bashecho "Usage: 1+3, qisquit" while [1] do read-p "->; >str 1 & gt; & gt/dev/nulla = ` echo $ str | awk-F '+|-| * |/' ' { print $ 1 } ' ` if[$ a = = q]thenrakfib = ` echo $ str | awk-F '+|-| * |/ ' ' { print $ 2 } ' ` o = ` echo $ str | grep-o "[:punct:]" | grep-v " \ "` case $ oin+)awk ' begin { printf " = % . 2f \ n ",' $ a '+' $ b ' } '; ; -)awk'BEGIN{printf"=%.2f\n ",' $ a '-' $ b ' } '; ; \*)awk'BEGIN{printf"=%.2f\n ",' $ a ' * ' $ b ' }; /)if[$ b-eq0]thene CHO 0 cannotbedenominator! continue fiawk ' begin { printf " = % . 2f \ n ",' $ a '/' $ b ' } '; ; #^)awk'begin{printf"=%.2f\n",'$a'**'$b'}'; ; *) echo error; ; Esacdone just wrote the reverse output: [root @ lixitingtestdir] # catdaoxushuchu.sh #! /bin/bashecho "Usage: 123456, QIs quit " while[ 1]do echo-n " Pleaswenternumber:" readnif[$ n = = ' q ']thenrakfisd = 0 rev = " on = $ necho " $ n " while[$ n-gt0] dosd = $($ n % 10))# getRemaindern = $(($ n/ 10))# getnextdigi