Hacker News new | ask | show | jobs
by rnk 895 days ago
I got tired of typing bc -l years ago, I have a function so I can do it on the command line: calc 2^27 + 3^15. I wish somehow the shell would let me add parens here, instead of having to escape them with a quote.

function calc2 { if [ $# -eq 0 ]; then echo 'pass commands for math evaluation, like calc l(2^32/17) + 3'; fi; echo $* | bc -l; }

1 comments

This is what I've had in my bashrc for a few years:

= () { printf "%'.f\n" $(echo $1 | bc); }; alias calc==