7is7.com > Software > Bash Scripts
Linux Penguin

Bash Scripts

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.

Quick maths

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.


Linux user 425492

Get Firefox! Download LibreOffice Use Fedora