Searching Wikipedia on the Linux command line with wikit

Searching Wikipedia on the Linux command line with wikit

Have you ever imagined looking up some topic on Wikipedia while you’re working on the Linux command line? What about displaying the results in a different language? Yes, it’s possible. In fact, it’s quite easy. The tool that provides this service is called wikit (Wikipedia IT).

To check if wikit is installed on your system, just type « which wikit ». If it is, you will get a response like this:

$ which wikit

If it’s not, you can install it, but you might need to first install nodejs which wikit depends on and maybe npm as well with a command like one of these:

$ sudo apt install nodejs npm	# Debian/Ubuntu
$ sudo yum install nodejs npm	# RHEL/CentOS
$ sudo dnf install nodejs npm	# Fedora

Install wikit using a command like this:

$ sudo npm install wikit -g

To try wikit out, type « wikit » followed by the topic that you’re interested in. For example:

$ wikit IDG
 International Data Group, Inc. (IDG) is a Massachusetts registered and
 headquartered media, events and research company focused on the tech
 landscape. Founded in 1964, it is made up of International Data Corporation
 (IDC) and IDG Communications; the latter includes the brands CIO magazine,
 Computerworld, CSO, InfoWorld, JavaWorld, Macworld, NetworkWorld, PCWorld,
 and TechHive. IDG was bought by China Oceanwide in 2017 while maintaining
 U.S. based leadership.

Some of the Wikipedia content is available in multiple languages. To get the response to the command shown above in French, for example, you could do this:

$ wikit --lang fr IDG
 IDG est un sigle qui peut signifier : * informatique de gestion ; * International
 Data Group, un groupe de presse américain ; * Indépendants de gauche,
 un groupe parlementaire sous la République française ; * Infrastructure
 de données géographiques, une organisation de partage d'informations géographiques
 ; * Initiative démocratique de gauche, un mouvement politique influant
 dans l'Aisne. IDG est un code qui peut signifier : *, Iowa, États-Unis,
 selon le code AITA des aéroports.

NOTE: To determine what letters to use to specify a particular language, visit this Wikipedia page with ISO 639-1 (codes for the representation of names of languages) codes.

Wikit will offer a list of possibly related topics if your search term appears ambiguous. This happens because this is the response that Wikipedia is providing. Wikit is simply passing your query to Wikipedia and delivering the results.

$ wikit idg
? Ambiguous results, "idg" may refer to: (Use arrow keys)
❯ IDG Ventures
  Apple Industrial Design Group
  Indigo Books and Music
  Makaziwe Mandela
  Australian Federal Police
  International Data Group
  Constant speed drive
  List of airports in Iowa
  Infinite derivative gravity

Some queries will require additional detail. For example, if we’re look to find out something about a very small town in Virginia, we might need more detail than just the town’s name:

$ wikit "Star Tannery"
Star Tannery not found :^(
$ wikit "Star Tannery, Virginia"
 Star Tannery is an unincorporated community in southwestern Frederick County,
 Virginia on the Shenandoah County line. Star Tannery is located on Star
 Tannery Road (State Route 604) off Wardensville Pike (State Route 55)
 along Cedar Creek. The Zip Code for Star Tannery is 22654.

Try to get relatively local information like this in another language and you’ll probably find it isn’t available.

$ wikit --lang de "Star Tannery, Virginia"
Star Tannery, Virginia not found :^(

One of the benefits of wikit is that you can pull reference information from Wikipedia and redirect it into a file that you’re building. For example, you might try a script like this:


cat list | while read line
   echo $line
   wikit "$line"

To use this script, you will need to have recognizable topics in your « list » file, one topic per line. Then run the script while redirecting its output to a file like this:

./getinfo > REPORT

Now see:

Join the Network World communities on
Facebook and
LinkedIn to comment on topics that are top of mind.

Copyright © 2020 IDG Communications, Inc.

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

web-breaking-news will use the information you provide on this form to be in touch with you and to provide updates and marketing.