Command line search utility
by Mostafa on Dec.27, 2005, under How To ..., Linux, Software
While studying for one of the finals this year, I felt the need for a CLI search utility that would search on Google, Wikipedia, Google Images, etc. I didn’t know of any tools that would already do this so I decided to write my own little bash script:
#!/bin/bash #Needs the htmlview package opt="$1" str="$2" #Create the search string until [ -z "$3" ] do str="$str+$3" shift done case "$opt" in "google" ) htmlview http://www.google.com/search?hl=en\&q="$str"&btnG=Google+Search & ;; "image" ) htmlview http://images.google.com/images?q="$str"\&safe=off & ;; "wpedia" ) htmlview http://en.wikipedia.org/wiki/Special:Search?search="$str" & ;; "scholar" ) htmlview http://scholar.google.com/scholar?q="$str"\&ie=UTF-8\&oe=UTF-8\&hl=en\&btnG=Search & ;; "ieee" ) htmlview http://ieeexplore.ieee.org/search/searchresult.jsp?queryText=\%28\%28"$str"\%29\%3Cin\%3Emetadata\%29 & ;; * ) echo "Usage: search engine searchterm [searchterms]" echo echo "Engines: google Basic Google websearch" echo " image Unfiltered Google image search" echo " wpedia Wikipedia (English)" echo " scholar Google Scholar" echo " ieee IEEE Xplore (needs subscription)" echo echo "Example: search image batman" ;; esac echo exit 0
It makes use of the htmlview package to discover the default browser and display the results. The use of the script is quite straightforward:
[darkknight@darkworld bin]$ search image batman begins
As is, it considers all search terms. Fancy things like Boolean expressions are not supported (yet :)). A copy of the script can be found here.
December 27th, 2005 on 10:37 pm
You forgot to mention which final you were studying for…