http://shell-calc.googlecode.com/
I just needed a powerful calculator (bitwise operators, hexadecimal
input/output, etc.), and found nothing appropriate.
Daniel.
I use:
calc() {
awk 'BEGIN { OFMT="%f"; print '"$*"'; exit}'
}
--
Chris F.A. Johnson, author <http://shell.cfajohnson.com/>
===================================================================
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
===== My code in this post, if any, assumes the POSIX locale =====
===== and is released under the GNU General Public Licence =====
And I use:
alias c "echo '\!*' | sed 's/:/;/g' | bc -l"
Once, though, I did something similar to what the OP proposes.
It was a C program that professed to be an expression evaluator.
The core of it was piping something into "gcc -" to create a shared lib,
then calling a function in that shared lib to get the "answer".
I use:
function ca ()
{
awk "BEGIN{ print $* }"
}
is it any different?
His version just has a bunch of little quibbles that you probably don't
care about. I won't go point-by-point, but note that the 'exit' in his
version is there just-in-case you are using an old, decrepit version of
AWK (the ones where it tries to read from standard input even if the
program consists of only a BEGIN clause).
What about zsh's zcalc? It seems to have all of the above plus
benefits from zsh's wonderful line editor.
http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#SEC289
--
Stᅵphane