Command-Line math 

Newsgroups: comp.os.linux.misc
Date: 8 Dec 2002 16:38:40 GMT
> I'm trying to come up with a Perl script that will allow me to type in a
> command-line math expression, push enter, and have the expression's evaluation
> printed in the terminal.  Here's a simple example:

Perl is overkill.

calc ()
{
    awk 'BEGIN {print '"$*"'}'
}
USAGE: calc expression
NOTE: Characters special to the shell must be escaped.

Chris F.A. Johnson

Command-Line math 

N=3*2
perl -e "print eval $N"

Chris F.A. Johnson