Search sites via Google and Terminal

Jun 06, '07 07:30:00AM

Contributed by: pamon

Here is a script that allows you to Google your query by typing it into Terminal:

#!/bin/sh

read F1
F=`echo $F1 | sed s/\ /+/g`

open "http://google.com/search?q=$F"
Copy and paste that into a new blank document in vi, pico, emacs, etc., and save it somewhere on your user's path. Then make it executable (chmod a+x googleit) and you can run it by typing googleit (or whatever you called it), pressing Return, and then entering your search term(s). You can't do a phrase search with this one -- try something quoted like "steve jobs and bill gates" and it will fail -- but I am hoping that someone here can come up with a solution.

There is more. I usually find myself googling something inside a website. The websites that have the answer are mostly limited (at least in my case), and that makes it a drag to type the same long web address into Google's search field every time I want to search for something. So I came up with a solution...

Here is a good example which looks up word(s) in Webster via Google:

#!/bin/sh

echo "type your word(s) to look up"
read F1
F=`echo $F1 | sed s/\ /+/g`

open "http://google.com/search?q=%20site:merriam-webster.com%20$F"

Here is another one to dig deep into wikipedia via Google:
#!/bin/sh

echo "type the query that you want to know about?"

read F1
F=`echo $F1 | sed s/\ /+/g`

open "http://www.google.com/search?as_sitesearch=en.wikipedia.org&fulltext=Search&=Google&q=$F"

Search macosxhints.com via Google:
#!/bin/sh

read F1
F=`echo $F1 | sed s/\ /+/g`

open http://google.com/search?q=%20site:macosxhints.com%20$F

Search the man pages at Apple.com via Google:
#!/bin/sh

read F1
F=`echo $F1 | sed s/\ /+/g`

open http://google.com/search?q=%20site:apple.com%20manual+page+for+$F

Search Apple's developer's website via Google:
#!/bin/sh

read F1
F=`echo $F1 | sed s/\ /+/g`

open "http://developer.apple.com/cgi-bin/search.pl?q=$F&num=10&site=default_collection"

Search Apple's support page via Google:
#!/bin/sh

read F1
F=`echo $F1 | sed s/\ /+/g`

open "http://search.info.apple.com/?q=$F&type=&search=Search&lr=lang_en&search=Go"

And finally, search Google Maps via Terminal:
#!/bin/sh

echo "where to?"
read F1
F=`echo $F1 | sed s/\ /+/g`

open "http://maps.google.com/maps?f=q&hl=en&q=$F"
Special thanks to James Reynolds for help with these scripts...

Comments (14)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2007060116541780