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 (ajayctk@gmail.com). 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 lookup Utility. 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 :
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 .
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 🙂
Great and important tool — I’m using it for a short scraping exercise, but dig is not working for me. Here’s what I got (sometimes an error and sometimes nothing):
$ dig +short txt linux.wp.dg.cx
;; connection timed out; no servers could be reached
$ dig +short txt linux.wp.dg.cx
$
I am using wikipedia2text instead (ubuntu 15.04) and that is working.
yay! It’s fun!!! By the way, if you need more about cli command… go here http://linuxcommand.org/.. hope this help…. 🙂
that is really cool trick will track back it
That’s a clever little trick but I can’t imagine why you’d need to use it when there are already command line web browsers that can display web pages (minus graphics and Flash of course) very well. Try Lynx or Links (http://www.jikos.cz/~mikulas/links//).
They’re certainly good enough for reading full wikipedia articles, browsing news sites and even searching around torrent sites.
Nice Info Bro..
in Addition anyone can use command line Lynx cli web browser .
check with this
en.wikipedia.org/wiki/Lynx_(web_browser)
Yup… Lynx :):)
Can it pull more than just a snippet, which abruptly ends in the middle of a sentence? A page at least?
It won’t work on every DNS (e.g. mine ;-)), but this one WILL work:
dig @8.8.8.8 +short txt 1984.wp.dg.cx
Thanks a lot. This example really work on my DNS. Could you explain how it work?
What’s the problem? Linux is about choice. So leave the user the choice which tool to use.
It is a quite nice trick that can be also used as a scrip in an irc.
To look up and redirect information in this way is a lot faster than clicking and copy/pasting information.
It would actually assist in creating GUI applications that require Wikipedia…
I do a lot of programming in Python and being able to pass this command would be useful for all types of things. Anyone else agree?
yup system call to this utility alongwith the wxpython , tkinter API’s of python can make a complete Wikipedia GUI Tool 🙂
If you enjoy searching from the command line, then you really should give Surfraw a go: http://surfraw.alioth.debian.org/
Nice Information In The Link!!!! Thanks A Lot Jason 🙂
Great tool! Thanks!
LOL. Thanks!
@theIdiotsPostingBeforeMe; For those of us who actually have jobs that require to use Linux, you may find yourself working on a server. Often enough, servers do not have GUIs because they do not require them. In this case, knowing how to quickly access a Wikipedia article could be quite useful.
Ford, I understand the concept. It’s not that difficult: access to information without GUI. However I’m failing to imagine the circumstance where you need access to encyclopedic knowledge while working on a server.
So before calling me an idiot you should probably think two steps ahead(not one) and try to visualize what _practical_ application is for this trick and not just the ability for the sake of ability. That is why I call it a trick. Its whole reason for existence is to impress. I doubt there’s something in wikipedia you would urgently need to configure or troubleshoot a server. Aren’t those the only two reasons you should use console on the server? Everything else including research you should probably do on your workstation. On the other hand I do all my work on servers through SSH. Cozy in front of my desktop. No cold air, no fan noise. No walking around looking for server, no looking for a key to open the cage. You know in datacenter mislabeling happens when you migrate 2000 servers. However I understand the desire to decrease the surface of attack and disable SSH. That’s prudent. But then again that’s what “dual-homed” topography is for. Do you feel me Ford?
My god! The things you find to waste your time on. If you are so technically inclined why not go and fix some bugs and really help. Whatever you discovered here is of no use to anyone. It’s a parlor trick and nothing more. I bet you this Sam Benny character who found it so “very useful” will try it out couple of times and forget about it for the rest of his life while in the mean time KDE for example is falling apart under idiotic leadership of juvenile eye-candy addicts.
Why do you care whether i try it or forget it. It doesn’t really matter to u. I express my views and I have the right to do it and you do not have any stupid reason to use my name in your comments.
very useful 🙂
So, still refusing the modern conveniences of desktop computing? Gotta do it like our grandparents? Browser just not good enough.
It’s Quite Useful When You Are Working On Console . You Don’t need to open up the browser in graphics console and look for the wikipedia page..
Because when you’re working on console you really really really need access to Wikipedia!
@pink We Respect Your Thoughts But We don’t agree with you on this
Who is “we”? The drone collective of CLI cult?
Mr. pink , no doubt you’re a pro in Linux or whatever ! maybe thats why you feel like its of no use !! but remember the time when u started using it , didnt you find things small things which you learned exciting and fascinating and , didnt you even told any friend near you about those tricks , like wow man ,” you gotta check this , this is awesome” . we do respect your views that “its not important at all ” (not to you) but everyone is not at the same level man !
P.s. Think it then ink it !