Command Line Calculator for csh (C Shell)

Just add

alias calc ‘awk “BEGIN{ print \!:1 }”;’

to your .alias or whatever-your-default-shell-file-is file.

Restart the terminal.

Example usage:

  • calc 4*4

Though, it gets a bit cluttery if you want to use parenthesis.

  • calc “1000000\*\(1.45\+6.2\)\/100″

You need to put the whole expression in double quotes and use the escape character “\” for every symbol (*,/,),(,+,-) you use in the expression.

But in the end, it works! :)

Update 1:

Just add

   alias calc ‘echo "\!:*" | bc -l’

to your .alias or whatever-your-default-shell-file-is file.

Restart the terminal.

Example usage:

  • calc 4*4
  • calc 1000000*(6.2+1.45)/100
  • calc 4^4 ( calculation of powers also works using bc! )

References: 1 2

Advertisement

One Response

  1. I dont disagree with you…

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.