Google Search from Linux Terminal [closed]

I saw a Google console app someone wrote a while back, but it was actually a website emulating a console.

What I'm after is a shortcut or Linux terminal app which I can use to quickly search Google.

Ideally, it will show the top 10 search results with numbers next to them, and pressing the number will open the site in a browser.

Having the Google results open in a browser is fine too.

Does anyone have a solution?


Solution 1:

google-cli is supposed to do just that (it's the revived version of cli-google).

Solution 2:

Here's a simple bash function that lets you type

google foo bar

and which will then open your default browser to display the Google results page for those search terms:

google() {
    search=""
    echo "Googling: $@"
    for term in $@; do
        search="$search%20$term"
    done
    xdg-open "http://www.google.com/search?q=$search"
}

Simply paste that in your terminal to give it a try.

For Windows or Mac OS X, substitute the last line with one of the following (assuming you are using Cygwin or similar on Windows):

Windows

start "http://www.google.com/search?q=$search"

Mac OS X

open "http://www.google.com/search?q=$search"

Solution 3:

#!/bin/bash

if [[ $(echo $*) ]]; then

    searchterm="$*"

else

    read -p "Enter your search term: " searchterm

fi

searchterm=$(echo $searchterm | sed -e 's/\ /+/g')

lynx -dump http://www.google.com/search?q=$searchterm | less

Copy and paste this script into ~/bin, name it "goose" or something (GOOgle SEarch). Chmod it +x

Usage is:

goose searchterm

Clearly, you have to have Lynx installed.