Google


Forum: DSL Ideas and Suggestions
Topic: Google
started by: SaidinUnleashed

Posted by SaidinUnleashed on May 12 2005,04:22
I seem to find myself relying on google almost as much as I do man, especially from the console.

And it gets tiring to type "links google.com" then whatever I'm wanting to search for.

So I did what any good geek would do, and wrote a script.

Just toss it into /usr/sbin and it works just like man.

For example:
Code Sample
google linux small 50mb


would search google for the words linux, small, and 50mb.

I made it to work with up to 9 words, but it's easy to increase this, and I'm sure you will be able to figure it out. :P But I rarely search for more than 6 words, so I figure 9 is plenty for most people.

Anyways, enough talk. Here's the code:
Code Sample
#/bin/bash

# man-like clone that searches google
# created by SaidinUnleashed, aka J.P. Nimmo

s1=$1
s2=$2
s3=$3
s4=$4
s5=$5
s6=$6
s7=$7
s8=$8
s9=$9

exec links http://www.google.com/search?\&q\=$s1\+$s2\+$s3\+$s4\+$s5\+$s6\+$s7\+$s8\+$s9


Remember to save it as "google" , and as root, move it to /usr/sbin, then as root, chmod +x it to make it executable by everyone.

Hope you find this handy.

-J.P.

Posted by mikshaw on May 12 2005,15:18
Cool!

how about this...
Code Sample

EDIT: BROKEN!
QUERY="links http://www.google.com/search?&q="
for WORD in "$@"; do QUERY="$QUERY+$WORD"; done
exec "$QUERY" <-- quotes break it =op

no editing for additional parameters

EDIT:
That'll larn me to script something without testing....
Code Sample
QUERY="links http://www.google.com/search?&q="
for WORD in "$@"; do QUERY="$QUERY+$WORD"; done
QUERY=`echo "$QUERY"|sed 's/\"/\%22/g'`
exec $QUERY

if you use a phrase with escaped quotes it will translate the quote into the URL:
google something \"something else\" blah

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.