Web Design

Categorized | Uncategorized, cli

Search Google.com from the Linux command line

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.

Author Profile

T4L ;

Other posts by T4L

Author's web site



Are you satisfied with this blog?
Why not subscribe our RSS Feed? you will always get the latest post.


8 Comments

  1. 1
  2. lsw

    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

    2
  3. lsw

    No need for curl to display on std output,

    html2text http://www.google.com/search\?q=search terms here

    will do

    3
  4. Sasha

    What’s the use of this?

    lynx is easier and more useful.

    4
  5. cozypaul

    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 ?

    5

  6. 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.

    6

  7. 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”.

    7
  8. Michael

    surfraw google -l -p TERMS

    8

4 Trackback(s)

  1. 09 08 2009 : Billy (seeds) 's status on Sunday, 09-Aug-09 05:25:50 UTC - Identi.ca
  2. 09 08 2009 : Twitted by linuxalive
  3. 13 08 2009 : Search Google from the command line « Linux & Stuff
  4. 13 08 2009 : Twitted by el_keogh

Leave A Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>