in reply to Re: •Re: Re: Simple command line calculator
in thread Simple command line calculator

You can make this take a command argument very easily. In fact you can replace the expr function with this:
function calc { perl -ple '$_=eval' } function expr { echo "$1" | calc }
Toku

Replies are listed 'Best First'.
Re: Re: Re: •Re: Re: Simple command line calculator
by Juerd (Abbot) on Mar 19, 2002 at 19:55 UTC

    How about a Perl solution?

    perl -le'print eval shift'
    Or, to slurp all arguments:
    perl -le'print eval "@ARGV"'

    U28geW91IGNhbiBhbGwgcm90MTMgY
    W5kIHBhY2soKS4gQnV0IGRvIHlvdS
    ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
    geW91IHNlZSBpdD8gIC0tIEp1ZXJk