Posts: 1,308
BitJam
Joined: 31 Aug 2009
#1
Add a line like this to your ~/.bashrc file (or run it in the command line):

Code: Select all

awkcalc () { awk"BEGIN{ print $* }" ;}
Then try it out:

Code: Select all

awkcalc 7 / 3
2.33333
If you added it to your .bashrc then you need to open up a new bash shell first.

I suggest you pick a shorter name that is easier to remember. Someone suggested naming it"?":

Code: Select all

? () { awk"BEGIN{ print $* }" ;}
? 7 / 3
2.33333
I had been relying on the bc calculator but it doesn't exist in the base flavour so I looked for alternatives.