Hide

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.

World cup college
Hide

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:

Hide

News

2010-03-18 - Top 10 commands explained
There's a great article by Peteris Krumins explaining the current top 10 commands: http://www.catonmat.net/blog/top-ten-one-liners-from-commandlinefu-explained/
2010-03-03 - Commandlinefu @ SXSW 2010
Am going to be at SXSW this year, in case you want to submit any CLI nuggets or suggestions to me in person. Ping me on the @codeinthehole Twitter account.
2009-09-12 - Email updates now available
You can now enable email updates to let you know each time you're command is commented on.
2009-07-11 - API and javascript blog widget now available
A simple API has been released, allowing commands to be retrieved in various formats. This also allows commands to be embedded on blogs/homepages.
Hide

Tags

Hide

Functions

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
97
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

#!/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.

Alternatives

There are 3 alternatives - vote for the best!

Terminal - Alternatives
mwiki () { blah=`echo $@ | sed -e 's/ /_/g'`; dig +short txt $blah.wp.dg.cx; }
mwiki() { dig +short txt "$*".wp.dg.cx; }
2010-03-27 17:54:36
User: dorin
Functions: dig
2

Shorter version, works with multiple words.

nslookup -q=txt <topic>.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 56 weeks and 5 days ago

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

Comment by Alanceil 56 weeks and 4 days ago

cute DNS abuse :)

Comment by penpen 56 weeks and 4 days ago

Very very cool.

Comment by qubyte 56 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 56 weeks and 4 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 56 weeks and 2 days ago

Script with prettified output:

cat wikisole.sh

#!/bin/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 56 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 56 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:

#!/bin/bash

function help {

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

exit

}

if [ -z "$1" ]; then

help

fi

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

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

SEARCH="$1"

else

SEARCH="$SEARCH $1"

fi

shift

done

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

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

echo ""

Comment by omish_man 56 weeks and 1 day ago

I hate dig.

Why not use:

host -t txt linux.wp.dg.cx
Comment by vutcovici 56 weeks ago

Simpler multiple words fix:

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

Comment by peter0081 51 weeks and 5 days ago
dig +short txt <keyword>.wp.dg.cx | espeak
Comment by matthewbauer 49 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 35 weeks and 3 days ago

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

Comment by sputnick 35 weeks and 3 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 32 weeks and 6 days ago

#! /bin/bash

echo please input your subject

read SUBJECT

dig +short txt SUBJECT.wp.dg.cx

Comment by ethnopunk 23 weeks and 5 days ago

Shorter version, works with multiple words:

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

Comment by dorin 22 weeks and 4 days ago

on windows:

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

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

Comment by bugmenot 2 weeks and 1 day ago

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

Comment by bugmenot 2 weeks and 1 day ago

Your point of view

You must be signed in to comment.

Related sites and podcasts