How To Search Google from the Command Line

google from the terminal

Ever had a hankering to search Google from the command line? If so, you’re going to love this nifty terminal tool.

It’s called Googler and, as you can probably guess, it’s a small command-line utility which lets you search Google from the terminal.

You’re not limited to regular Google web search either as the python-based tool lets you use Google site search and probe Google News for content that matches your chosen query(s).

As a search tool the way search results are presented is important — and thankfully it really delivers.

When you search from the command-line using Googler you’re presented with a list of search results that show the title, URL and a short text snippet. You can quickly open any result in a web browser by entering the number that corresponds to the result you want to read.

A stack of other search options and parameters are available for more advanced users. These let you search for an exact phrase, search a specific version or Google, and/or narrow down search results based on a specific time period.

Now, I’m not for one moment suggesting that Googler (or command line search in general) is the most practical way to find stuff on the web. It’s not. But it is novel, inventive, and, for those who spend a lot of time staring down a blinking underscore at the command line, potentially handy in a pinch.

Googler Lets You Search Google from the Terminal

Googler was created to let people make web searches on a headless server lacking an X session, where it could integrate neatly with a text-based browser. In such situations it provides a fully immersive command-line web search experience.

But the inherent niftiness of the tool, combined with the novelty of being able to Google from the terminal, has seen it pick up an army of admirers on the regular desktop too — and a boat load of new features to boot.

You can limit the number of results; define an alias to perform site searches (e.g., omgubuntu plank themes; use a specific locale version; and, well, a bunch more besides!

I must stress that Googler is not affiliated, endorsed or supported by Google itself. It’s an unofficial, unrelated, third-party project. It is open-source. Code is available on Github.

Install Googler on Ubuntu

It’s easy to install Googler on Ubuntu 16.10 or above: just click this button to install it from Ubuntu Software:

Click to install Googler on Ubuntu

Or, from the command line, run:

sudo apt install googler

If you’re running Ubuntu 16.04 LTS you can download and install an installer from this PPA:

Googler Installer for Ubuntu 16.04 LTS

Once installed Googler is immediately available and ready to use. Simply pop open your favourite terminal emulator and punch in the single command:

googler

Googler will then prompt you to enter a search query. Quickly type a phrase or two and hit the return key. The app will print a list of matching results.

Google Command Line Search Options

Googler may be effortlessly simple to use, but for the times you need more finesse and control over search results there are a stack of options ready to assist.

You can type googler --help to see a full list of available arguments, options, and flags. Or, if you’re lazy, you can see them in this image:

googler commands

The ones I find most useful are --count and --time which (shock) lets you limit how many search results you see, and the time period from which they’re chosen.

So, for example, I I want to see the top 4 results about hamsters, limited to things published in the last 5 hours, I run:

googler --count 4 --time h5 hamsters

google command line search using Googler on Ubuntu

Simple enough, isn’t it?!

Got a top terminal tool you think we should write about? Stuff a link and some info in our mailbox and we’ll check it out.

Source