Spotlight | Reviews | Current Issue | Academy | Newsletter | Subscribe | Shop |
Departments

Partner Links
Make your own website
WinWeb OnlineOffice
Comparing prices of hardware is worth it.
Price Comparison
What:
Where:
Country:
vacatures Netherlands njobs Linux vacatures
arbeit Deutschland njobs Linux arbeit
work United Kingdom njobs Linux jobs
Lavoro Italia njobs Linux lavoro
Emploi France njobs Linux emploi
trabajo Espana njobs Linux trabajo

user friendly

Admin Magazine

ADMIN Network & Security

Subscribe now and save!

 ADMIN - Explore the new world of system administration! ADMIN is a smart, technical magazine for IT pros on heterogeneous networks. Each issue delivers technical solutions to the real-world problems you face every day. Learn the latest techniques for better:

  • network security
  • system management
  • troubleshooting
  • performance tuning
  • virtualization
  • cloud computing

 on Windows, Linux, Solaris, and popular varieties of Unix.

http://www.admin-magazine.com/

  linux-magazine.com » Online » Blogs » Productivity Sauce » Lookup Words from the Command Line Using a Simple Bash Script  

Productivity Sauce
Productivity Sauce

Lookup Words from the Command Line Using a Simple Bash Script

The humble nano text editor can be a rather handy distraction-free drafting tool, but now and then I need to look up words and their definitions in WordNet. To do that, I tweaked a simple Bash script I stumbled upon on the Stack Overflow Web site. The original script pulls data from the Google Define source, but it took just a few minutes to make it work with WordNet. So if you, like me, need to look up words and their definitions without leaving the terminal, here is a script that can help you with this:

#!/bin/bash
echo "Enter your word:"
read word

/usr/bin/curl -s -A 'Mozilla/4.0' 'http://wordnetweb.princeton.edu/perl/webwn?s='$word \ 
| html2text -ascii -nobs -style compact -width 500 | grep "*"

For this script to work, you need to install curl and html2text packages. On Ubuntu, you can do this using the sudo apt-get install curl html2text command. Copy and paste the script text into a blank text file, save it as the wn.sh script, and make it executable using the chmod +x wn.sh command. Now you can run the script by issuing the ./wn.sh command.

Obviously, you can use this script with any other online resource. All you have to do is to replace the existing query URL with your own and tweak the parameters of the html2text command.

Comments

500 words

www.cloneget.com Aug 17, 2010 8:59am GMT

Great Blog here my friend! Very informative, I appreciate all the information that you just shared with me very much and I'll be back to read more in the future.

My version for looking up words

Phat Doan Aug 04, 2010 4:18pm GMT

If you use Debian, with an installation 'apt-get install wordnet' then the whole dictionary is in your computer. The following script is ideal for reader, since it just looks up definitions and no more. As a result, it save some more space on the screen and is easier to look.


#! /bin/bash
wn $1 -over | less

And as an option, like Joe Klemmer suggested, you can customize the code so that it would prompt to enter a word if you forget to do so.That's it. Very simple.

Re: Lookup Words from the Command Line Using a Simple Bash Script

Joe Klemmer Aug 03, 2010 7:52pm GMT

I did a little tweaking of this script, if that's ok. This will let you enter the word to look up on the commandline or, of no word is passed, prompt the user for it.

#!/bin/bash

echo ""

if [ "x$1" == "x" ] ;
then
echo -n "Enter your word: ";
read word;
else
word=$1;
fi

/usr/bin/curl -s -A 'Mozilla/4.0' 'http://wordnetweb.princeton.edu/perl/webwn?s='$word | html2text -ascii -nobs -style compact -width 500 | grep "*"


Side note:
It might be easier to use the dict utility in some cases. If it isn't installed on your system just run -

# yum install dictd

The output is formatted much cleaner and it returns more information.

Print this page. Recommend
Share