Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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; }



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

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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: