What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. 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.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Universal configuration monitoring and system of record for IT.

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:



2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.

Top Tags



Query Wikipedia via console over DNS

Terminal - Query Wikipedia via console over DNS
dig +short txt <keyword>.wp.dg.cx
2009-07-31 16:08:59
User: drizzt
Functions: dig
Query Wikipedia via console over DNS

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


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.


There are 14 alternatives - vote for the best!

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

Shorter version, works with multiple words.

mwiki () { blah=`echo $@ | sed -e 's/ /_/g'`; dig +short txt $blah.wp.dg.cx; }
nslookup -q=txt <topic>.wp.dg.cx
wiki() { local IFS=_; dig +short txt "${*^}".wp.dg.cx; }
mwiki () { dig +short txt `echo $*|sed 's| *|_|g'`.wp.dg.cx; }

Know a better way?

If you can do better, submit your command here.

What others think

this is awesomely wacky

Comment by unixx 299 weeks ago

Vote this up. One can feel the awesome behind this command :-)

Comment by Alanceil 299 weeks ago

cute DNS abuse :)

Comment by penpen 298 weeks and 6 days ago

Very very cool.

Comment by qubyte 298 weeks and 6 days ago

We can add some GUI spice to teh absue :P , dep==> zenity

zenity --info --text="$(dig +short txt $(zenity --entry --title="Search wiki" --text="Enter your search word:").wp.dg.cx)"

Comment by hemanth 298 weeks and 6 days ago

This is simply awesome. In the shell script example, add quotes around the "${1}" and you can do multi-word searches using quotes in your arg, like:

./wikip.sh "gradient descent"
Comment by zombiedeity 298 weeks and 4 days ago

Script with prettified output:

cat wikisole.sh


COLUMNS=`tput cols`

dig +short txt "${1}".wp.dg.cx | sed -e 's/" "//g' -e 's/^"//g' -e 's/"$//g' -e 's/ http:/\n\nhttp:/' | fmt -w $COLUMNS

Comment by philipsd6 298 weeks and 3 days ago

philipsd6's version as a function in bashrc:

function wiki () {

COLUMNS=`tput cols`

dig +short txt ${1}.wp.dg.cx | sed -e 's/" "//g' -e 's/^"//g' -e 's/"$//g' -e 's/ http:/\n\nhttp:/' | fmt -w $COLUMNS


Comment by bstaz 298 weeks and 3 days ago

You can also search for more than one word like this:

dig +short txt "multiple words".wp.dg.cx

I wrote a wrapper script that takes either 1 word or multiple words and formulates the syntax properly:


function help {

echo -e "\n\tusage: $0 "



if [ -z "$1" ]; then



while [ "$1" != "" ]; do

if [ "$SEARCH" = "" ]; then







echo -e "\n\tLooking up $SEARCH\n"

dig +short txt "$SEARCH".wp.dg.cx

echo ""

Comment by omish_man 298 weeks and 3 days ago

I hate dig.

Why not use:

host -t txt linux.wp.dg.cx
Comment by vutcovici 298 weeks and 2 days ago

Simpler multiple words fix:

dig +short txt "`echo $@`".wp.dg.cx

Comment by peter0081 294 weeks and 1 day ago
dig +short txt <keyword>.wp.dg.cx | espeak
Comment by matthewbauer 291 weeks and 6 days ago

I wonder if we can do that with French language ( fr.wikipedia.org )

Like with this example : fr.wikipedia.org/wiki/Tse

Comment by sputnick 277 weeks and 5 days ago

OOps, http://fr.wikipedia.org/wiki/Services_de_terminal

Comment by sputnick 277 weeks and 5 days ago
mwiki () { echo $@ > foo; blah=`sed 's/ /_/g' foo`; dig +short txt $blah.wp.dg.cx; }

Sample output:

mwiki snow leopard

"The snow leopard (Uncia uncia or Panthera uncia), sometimes known as \"ounce,\" is a moderately large cat native to the mountain ranges of Central Asia. The classification of this species has been subject to change and its exact taxonomic position is still " "unclear.

Comment by oshazard 275 weeks and 1 day ago

#! /bin/bash

echo please input your subject


dig +short txt SUBJECT.wp.dg.cx

Comment by ethnopunk 266 weeks and 1 day ago

Shorter version, works with multiple words:

mwiki() { dig +short txt "$*".wp.dg.cx; }

Comment by dorin 265 weeks ago

on windows:

nslookup -q=txt shit.wp.dg.cx
Comment by unixmonkey9108 264 weeks and 2 days ago

"slookup -q=txt" does not appear to be valid (i have WinXP+SP3)...

Comment by bugmenot 244 weeks and 3 days ago

sorry, in mean "Nslookup -q=txt"...

Comment by bugmenot 244 weeks and 3 days ago

Nice. These dns lookups seems faster than an actual http request.

But I don't like the disturbing " and \ and the missing linebreaks. Therefore by combining dorin's ID with a sed and fmt I get to:

mwiki() { dig +short txt $(echo $* | sed 's/ /_/g').wp.dg.cx|sed -E "s/\" \"|^\"|\"$|\\\\//g"|fmt; }
Comment by unixmonkey12820 236 weeks and 6 days ago

what do you need this for?

has it some advantages to to such a query over DNS?

why can't you use curl instead?

Comment by rubo77 235 weeks and 3 days ago

how to convert the utf-8 encode result to itf-8?

e.g. when I query "Leon", I got "L\195\169on".

I tried to convert is using "echo -e", but echo only support \xC3\xA9 format.

Comment by hileon 141 weeks and 1 day ago

This command is great.

But when I run it now I get:

;; connection timed out; no servers could be reached

Anyone know what's wrong? I looks like Wikipedia is blocking dns requests or something else has changed.

Comment by JokesOnYou 116 weeks ago

JokesOnYou ... not sure exactly but you can stipulate the nameserver to query as a swich to dig, ie (using opendns).

dig @resolver1.opendns.com +short txt "${1}".wp.dg.cx

Comment by khayyam 109 weeks and 1 day ago

But does this work?~

Comment by ohuhu 73 weeks and 2 days ago

I mean how does this work

Comment by ohuhu 73 weeks and 2 days ago

The guy who made it possible: https://dgl.cx/wikipedia-dns

@sputnick Like said in the link above, this is a special nameserver that returns a short description of the query. So the article language is handled at server side.

Comment by dinorox 62 weeks and 6 days ago

Your point of view

You must be signed in to comment.