6

This question already has an answer here:

I know the program launchy from Windows (and it is also available in Ubuntu) in which I can simply enter 100/9.14 and get the result without opening a calculator. But I don't want to install the whole program just to do that...

Is there a simple command line tool I can use?

marked as duplicate by steeldriver, Jacob Vlijm, muru, roadmr, Eliah Kagan Sep 6 '14 at 0:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • There are many, many (many) other options: unix.stackexchange.com/questions/40786/… – Jacob Vlijm Sep 5 '14 at 19:17
  • The question, as written, is not a duplicate since the user was looking for a graphical solution similar to Launchy. The appropriate approach is to use the 14.04 built-in Unity Calculator Scope. Open the Dash, click on Filter Results to expand it, select Calculator under Source, and then close the Dash. Now, whenever you want to use the Calculator Scope (1) Open the Dash. (2) Type the equation. (3) The result appears in the Dash under the Calculator icon in the Info section. – PJ Singh Sep 6 '14 at 0:58
  • @PJSingh You might have missed the section about a simple command line tool I can use. Hem mentions he knows Launchy, not that he is looking for a GUI solution – Jacob Vlijm Sep 7 '14 at 12:52
7

I'd start a python interpreter to perform such simple operations:

$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 100/9.14
10.940919037199125
>>> 

Please check this link for a list of python mathematical operators.

3

Use bc, it does exactly what you want and it also has some other features, like variables, configurable input/output base (great for converting hex/dec/bin and so on) and others.

  • 1
    IMO this is the right answer, but would be better if examples were given. – Digital Trauma Sep 5 '14 at 23:20
3

The answer suggesting bc is certainly a good way to go. However, I like it even better with this simple wrapper, which I discovered quite serendipitously:

#!/usr/bin/env sh
#
# pbrisbin 2013 - see: https://github.com/pbrisbin/scripts/blob/master/calc
#
###
if which bc &>/dev/null; then
printf "scale=10; $*\n" | bc -l
else
awk "BEGIN { print $* }"
fi

As you can see, the idea was taken from pbrisbin.com, which is a site packed full of great ideas like these. (His goodsong script, e.g., made MPD become at least twice as awesome....)

2

I would recommend/install synapse.

Ubuntu 12.04 and below: sudo apt-get install synapse
Ubuntu 14.04: Is synapse application launcher available?

Launch synapse by searching for it in the dash and go to the preferences menu. You can use the synapse indicator to access the preferences.

Once the window opens up, click the plugins tab and enable the Calculator plugin.

See below:

enter image description here

Once done, anytime you launch synapse using Ctrl + Space you can just start typing your calculation and the results will be displayed in realtime.

See below:

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.