You are not logged in.
just add this line into ~/.bashrc
calc(){ awk "BEGIN{ print $* }" ;}
ex:
$ calc "(1*2)+4-(5-6)"
7
or
$ calc 128*3
384
Offline
Or using just bash:
calc(){ echo $(( $1 )); };
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
Being integer only, bash truncates results from divisions. For example, 16 divided by 9 (1.777…) results in 1. If you want to get rounded results, multiply the left operand by ten, add 5 to the result and divide that by 10.
[user@localhost ~]# function divide() { echo $(( ($1 * 10 / $2 + 5) / 10 )); }
[user@localhost ~]# echo $(( 16 / 9 ))
1
[user@localhost ~]# divide 16 9
2
[user@localhost ~]# echo $(( 4 / 3 ))
1
[user@localhost ~]# divide 4 3
1
Last edited by apaige (2009-11-11 18:00:38)
Offline
Another bc liner
% alias calc='bc -l <<<'
% calc 'r=5; pi=3.14; pi*r^2'
78.50
You need to install an RTFM interface.
Offline