Shell calculator?

Discussion in 'Linux, BSD and Other OS's' started by Addis, Feb 14, 2006.

  1. Addis

    Addis The King

    Likes Received:
    91
    Trophy Points:
    48
    I was trying to find a a calculator in bash? Anyone know if one exists, preferably a simple "eval 22 / 7" syntax.

    I had to resort to writing a small C++ one, but I'm sure there must be a good one somewhere.
     
  2. Anti-Trend

    Anti-Trend Nonconformist Geek Staff Member

    Likes Received:
    118
    Trophy Points:
    63
    There are two shell calculators that I know of that are standard GNU/Linux tools: expr and bc.
     
  3. BecauseRobots

    BecauseRobots Geek Trainee

    Likes Received:
    0
    Trophy Points:
    0
    Another alternative if you're using bash (which you probably are) is something simple like

    function calc() { echo $[$*]; }

    Note, you can't have spaces in your expression, but that's not a big deal. use it like "calc 2*3**4" (note ** is the exponential operator, you can man bash for the others.)

    *link removed*. Site Pimping is not allowed.
    - RH
     

Share This Page