Bash Math - Raspberry Pi Forums


trying multiply var mps * 2.236936 current value 0.005 of mps var, cant mulyiply save life.

code: select all

tpv=$(gpspipe -w -n 5 | grep -m 1 tpv | cut -d, -f4-14) lock=$(echo $tpv | cut -d, -f1 | cut -d: -f2) lat=$(echo $tpv | cut -d, -f4 | cut -d: -f2) lon=$(echo $tpv | cut -d, -f5 | cut -d: -f2) alt=$(echo $tpv | cut -d, -f6 | cut -d: -f2) trk=$(echo $tpv | cut -d, -f10 | cut -d: -f2) mps=$(echo $tpv | cut -d, -f11 | cut -d: -f2) echo "lock" $lock echo "lat" $lat echo "lon" $lon echo "alt" $alt echo "trk" $trk if [ "$lock" -gt "2" ]         echo "good" else         echo "bad" fi 

the arithmetic available within bash shell deals integer values.

man bash:

code: select all

arithmetic evaluation        shell allows arithmetic expressions evaluated, under         circumstances  (see let , declare builtin commands , arithmetic        expansion).  evaluation done in fixed-width integers  no  check         overflow, though division 0 trapped , flagged error. 


raspberrypi



Comments

Popular posts from this blog

Authentication error while password reset - Raspberry Pi Forums

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums