Google Search from Linux Terminal
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"
google-cli is supposed to do just that (it's the revived version of cli-google).
#!/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.