This page contains a selection of simple Bash scripts (on Linux and UNIX) that I have collected. It's more of a memo to myself and not intended as a guide or anything. So just see it as notes that I share with whoever is interested.
Create a script that will treat its argument(s) as a mathematial argument. This script needs just two lines:
res=$(echo "scale=12; $*" | bc -l) [[ -n ${res//[^\.]/} ]] && res=$(echo $res | sed -e 's/\.\?0*$//')
It removes trailing 0s and the period if needed and has a precision of up to 12 digits after the dot.