You can search Google.com from the Linux command line without using a CLI web browser like lynx or Elinks. All you need is the curl and html2text packages installed. Then you issue the following command:
curl -A Mozilla http://www.google.com/search?q=Linux |html2text -width 80
where you can replace Linux with another keyword of your choice. The results will be displayed in your console application with a width of 80.
The 70-646 training kit includes the N10-004 questions and 1Y0-A17 answers so you will pass your exam on first try guaranteed.
slightly shorter:
lynx -dump http://www.google.com/search?q=Linux
I use this script, works in X or in a VT: I have links2 with the framebuffer enabled so you may want to change or remove the LOPTIONS part that runs links in graphics mode.
if [ -z “$1” ]; then
echo “Usage: google searchterm1 searchterm2 … ”
exit 1
else GSEARCH=”http://www.google.com/search?hl=en&q=$*&btnG=Google+Search”
fi
if [ -n “$DISPLAY” ]; then
firefox “$GSEARCH” &
else
if tty|grep -q “tty” ; then LOPTIONS=”-g -driver fb” ; fi
links2 $LOPTIONS “$GSEARCH”
fi
exit 0
No need for curl to display on std output,
html2text http://www.google.com/search\?q=search terms here
will do
What’s the use of this?
lynx is easier and more useful.
Pingback: Billy (seeds) 's status on Sunday, 09-Aug-09 05:25:50 UTC - Identi.ca
Pingback: Twitted by linuxalive
Pingback: Search Google from the command line « Linux & Stuff
Pingback: Twitted by el_keogh
that’s quite nice, but doesn’t work with zsh actually:
pingo% env|grep -i shell
SHELL=/usr/bin/zsh
XTERM_SHELL=/usr/bin/zsh
pingo% lynx -dump http://www.google.com/search?q=Linux
zsh: no matches found: http://www.google.com/search?q=Linux
under bash works properly…
any idea why ?
I stuck a script in ~/bin, named it “goose” (GOOgle SEarch) like this:
#!/bin/bash
lynx -dump http://www.google.com/search?q=$* | less
I do
:~$ goose cows
or whatever.
Using less makes it easier to view the output, imho.
All using html2text gives me is:
:~$ html2text http://www.google.com/search\?q=cows
Cannot open input file “http://www.google.com/search?q=cows”.
surfraw google -l -p TERMS
if [ -z “$1” ]; then
echo “Usage: google searchterm1 searchterm2 … ”
exit 1
else GSEARCH=”http://www.google.com/search?hl=en&q=$*&btnG=Google+Search”
fi
if [ -n “$DISPLAY” ]; then
firefox “$GSEARCH” &
else
if tty|grep -q “tty” ; then LOPTIONS=”-g -driver fb” ; fi
links2 $LOPTIONS “$GSEARCH”
fi
exit 0
How to use this script? Seems to be usefull..