Mar 262012
 

Original article by Ankur Aggarwal published on http://flossstuff.wordpress.com/

Wikipedia : One of the most important web portal in  geek’s life. Whenever I need to search anything I use two things. First open up the Google and then search for the related  wikipedia page. Exploring wikipedia page using shell is possible. Interested fact is that we can do it without even opening the cli browser. We can make wikipedia text query over dns for an ip address. I learned this trick from Ajay Sharma ([email protected]). Thanks to him for teaching me this wonderful trick. Let’s explore how to do it.



We will use ‘dig‘ utility for this purpose. Dig is more popularly known as the DNS lookupUtility. You can find more about it using  man pages. Syntax for the text based wikipedia query is : dig +short txt <keyword>.wp.dg.cx . For example if you want to look into the wikipedia page of Linux you need to type something like this : dig +short txt  linux.wp.dg.cx . Screenshot of the same is attached below :

screenshot-1

Making A Wikipedia Query In CLI

For multiple word search having spaces in between them you can use the traditional ‘\’ operator. To grasp the wikipedia page  of  Free Software Foundation (FSF) we need to type dig +short txt  free\ software\  foundation.wp.dg.cx . 

fsf_search

Only problem is its quite limited. I am trying to figure out a way through which we can look up the whole page but I think this much is also quite useful as most of the times we came to know about the product by reading one or two lines only. So play with wikipedia using Shell only

Popular Posts:

Flattr this!

  8 Responses to “Search Wikipedia Through CLI (Shell) In Linux”

  1. very useful tip. keep it up and keep posting the updates.

  2. Just use Surfraw. Homepage: http://surfraw.alioth.debian.org
    Surfraw provides a fast unix command line interface to a variety of
    popular WWW search engines and other artifacts of power. It reclaims
    google, altavista, dejanews, freshmeat, research index, slashdot
    and many others from the false-prophet, pox-infested heathen lands of
    html-forms, placing these wonders where they belong, deep in unix
    heartland, as god loving extensions to the shell.

  3. ma perche la gente posta in inglese? se l’articolo e’ in italiano?

    • Sito bilingue, gli articoli sono disponibili sia in Inglese che italiano 😉

      • Bilingue e con i commenti unici? Non male come idea, io non ci avevo pensato e chiedo come ci si trova. Ci saranno sicuramente dei punti deboli di quest’approccio.

        Comunque anch’io sto rivalutando l’uso della shell che è molto comoda. Per esempio ho cercato per diletto se ci fossero dei domini liberi e agendo tramite browser o tramite whois via web la cosa si fa molto lunga e tediosa.

        Invece da cli basta un whois seguito dal dominio di secondo e primo livello e il gioco è fatto.

        • Ciao Sandro,
          Io come gestore trovo i commenti unici molto comodi, ma magari non tutti gli utenti la pensano così 😉
          Poi l’avere il sito in bilingue ha dei pro (maggiore utenza) e dei contro (ogni articolo deve essere scritto due volte, cosa che rende la frequenza più bassa dei siti mono lingua.

          E si, concordo pienamente che con un po di pratica con la shell si può fare con pochi comandi lavori altrimenti lunghi e ripetitivi.

  4. Neat trick! I just created a function around it. Here it is:

    function wik() { if [ "$1" != "" ]; then dig +short txt $1.wp.dg.cx; fi }

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*