Skip to content

Latest commit

 

History

History
22 lines (13 loc) · 362 Bytes

File metadata and controls

22 lines (13 loc) · 362 Bytes

Get the directory of the current running script

$(dirname "$(readlink -f "$0")")

Arithmetic operations in BASH

Use the bc command:

$ echo '2*2' |  bc
4

and the scale special argument for floating point numbers:

$ echo 'scale=2; 1/3' | bc
.33

Round numbers

Use the printf command:

$ printf '%.2f' '0.3333333'
0.33