Create a command-line calculator

Dec 30, '01 11:01:03PM

Contributed by: Anonymous

I love this, even though I didn't think of it myself. ;-)

Want a simple calculator that works at the Terminal prompt? As per the suggestion on this website, just put this in your ".cshrc" (or "aliases.mine" as the case may be):

alias calc 'awk "BEGIN{ print \!* }" ' 
That's it. Then run
% source .cshrc
% rehash
and you can do basic arithmetic in the Terminal application:
% calc 545+56
601
% calc 545-56
489
% calc 545*56
30520
% calc 545/56
9.73214
I like this especially because now I don't have to use the wretched Numlock key on my iBook.

Comments (6)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20011230230103566