Skip to content

Instantly share code, notes, and snippets.

@abi
Created December 6, 2010 05:33
Show Gist options
  • Save abi/729922 to your computer and use it in GitHub Desktop.
Save abi/729922 to your computer and use it in GitHub Desktop.
A simple script that searches Google and copies the first result link to your clipboard. Usage : google "julian assange"
#chmod a+x {this_file} to make executable and add it to $PATH
query=$(echo $1 | sed 's/ /\+/g')
curl -A "Mozilla/2.01" "http://www.google.com/search?source=ig&hl=en&rlz=&q=$query&btnG=Google+Search" 2>/dev/null|
tr '>' '\n' 2>/dev/null|
grep "<h3 class=\"r\"" -A 1|
grep "href="|
sed 's/.*href="//'|
sed 's/".*//'|
head -n 1 |
pbcopy |
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment