|
|
|
|
|
by sillysaurus3
3198 days ago
|
|
Throw this in your ~/bin as a script named math: #!/bin/sh
scale=4 # results will print to the 4th decimal
echo "scale=$scale; $@" | bc -l
Now you can do math. $ math '1+1'
2
$ math '2/3'
.6666
This is especially useful in shell scripts with interpolated variables: x=10
x=`math $x - 1`
|
|