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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

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 is 1 alternative - 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 308 weeks and 5 days ago

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

Comment by Alanceil 308 weeks and 4 days ago

cute DNS abuse :)

Comment by penpen 308 weeks and 4 days ago

Very very cool.

Comment by qubyte 308 weeks and 4 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 308 weeks and 3 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 308 weeks and 1 day 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 308 weeks and 1 day 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 308 weeks and 1 day 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 308 weeks ago

I hate dig.

Why not use:

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

Simpler multiple words fix:

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

Comment by peter0081 303 weeks and 5 days ago
dig +short txt <keyword>.wp.dg.cx | espeak
Comment by matthewbauer 301 weeks and 4 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 287 weeks and 2 days ago

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

Comment by sputnick 287 weeks and 2 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 284 weeks and 6 days ago

#! /bin/bash

echo please input your subject


dig +short txt SUBJECT.wp.dg.cx

Comment by ethnopunk 275 weeks and 5 days ago

Shorter version, works with multiple words:

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

Comment by dorin 274 weeks and 4 days ago

on windows:

nslookup -q=txt shit.wp.dg.cx
Comment by unixmonkey9108 274 weeks ago

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

Comment by bugmenot 254 weeks and 1 day ago

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

Comment by bugmenot 254 weeks and 1 day 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 246 weeks and 4 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 245 weeks 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 150 weeks and 5 days 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 125 weeks and 4 days 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 118 weeks and 5 days ago

But does this work?~

Comment by ohuhu 82 weeks and 6 days ago

I mean how does this work

Comment by ohuhu 82 weeks and 6 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 72 weeks and 4 days ago

It didn't work as expected. Blocked by Wikipedia?

Comment by cwchentw 6 weeks and 4 days ago

For those wondering, it's a part of the dnsutils package on Debian.

Comment by scurge 5 weeks and 6 days ago

Your point of view

You must be signed in to comment.