Or:
echo "$1" | bc -l
No need to rev up python. echo "$1" | bc -l
No need to rev up python. from math import *
Which gives you significantly more options.I love this idea, I have always found math in the command line to be clunky.
In any case, since I have emacs open all time, I usually do
M-x calc
for one-off calculations. function calc {
print $1 | bc -l
}
Then: calc "(1+2)*3"
9
zsh actually comes with its own little calculator: zcalc "(1+2)*3"
1> 9
2>
Among other things, it features "full command line editing, including the history of previous calculations". $ bc -l <<< 3+2
5
$