Query Wikipedia via console over DNS

wki () { dig +short txt "${*// /_}".wp.dg.cx | sed -e 's/^"\(.*\)"$/\1/' -e 's/\([^\]\)"[^\]*"/\1/g' -e 's/\\\(.\)/\1/g' }
This removes the enclosing quotation marks ("), and sticthes the different packets together, e.g. '
Sample Output
$ wki a
The letter A is the first letter in the Latin alphabet. Its name in English is a ; the plural is aes or, more commonly, a's. The letter A can be traced to a pictogram of an ox head in Egyptian hieroglyphs or the Proto-Sinaitic alphabet. http://en.wikipedia.org/wiki/A

By: kovirobi
2012-05-30 11:36:25

6 Alternatives + Submit Alt

  • Query Wikipedia by issuing a DNS query for a TXT record. The TXT record will also include a short URL to the complete corresponding Wikipedia entry.You can also write a little shell script like: $ cat wikisole.sh #!/bin/sh dig +short txt ${1}.wp.dg.cx and run it like ./wikisole.sh unix were your first option ($1) will be used as search term. Show Sample Output

    dig +short txt <keyword>.wp.dg.cx
    drizzt · 2009-07-31 16:08:59 105
  • Shorter version, works with multiple words. Show Sample Output

    mwiki() { dig +short txt "$*".wp.dg.cx; }
    dorin · 2010-03-27 17:54:36 1

  • 6
    mwiki () { blah=`echo $@ | sed -e 's/ /_/g'`; dig +short txt $blah.wp.dg.cx; }
    oshazard · 2010-01-16 07:13:43 0

  • 2
    nslookup -q=txt <topic>.wp.dg.cx
    bandie91 · 2010-05-02 21:37:51 0

  • 2
    wiki() { local IFS=_; dig +short txt "${*^}".wp.dg.cx; }
    RanyAlbeg · 2011-09-16 00:12:42 5

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: