BSD DevCenter
oreilly.comSafari Books Online.Conferences.

advertisement


Working With Text
Pages: 1, 2

Let's say you're typing out that memo to your boss and you can't remember if the word "actually" has one or two "l"s. The quickest way to find out is to run the look utility at another virtual terminal like so:



look actual
actual
actualism
actualist
actualistic
actuality
actualization
actualize
actually
actualness

Notice that I just supplied the root word "actual" and received all of the possibilities that could be added to that root, including the one I was looking for. I've yet to find a quicker way to get the correct spelling of a word, along with other possibilities that I may actually prefer.

However, if you are a terrible speller, you may prefer an interactive spell checker that will check an entire document for you. Both aspell and ispell in the ports collection will do this for you. Both utilities can be run from the command line, and aspell can be integrated into e-mail readers and other editors. Let's take a quick look at both; I'll start with ispell. If you've installed the ports collection, become root, make sure you're connected to the Internet, and type:

cd /usr/ports/textproc/ispell
make && make install

When it's finished installing, leave the superuser account. If you are in the C shell, type:

rehash

Now let's create a quick text file with some spelling mistakes:

cd ~
cat > typos
This is a very quik file
to demunstrate my
terruble spelling.
^d

To spellcheck this file using ispell, type:

ispell typos

which will highlight the first mispelled word and give you various options on dealing with the misspelling like so:

  quik		File: typos

This is a very quik file 

00: quib
01: quick
02: quid
03: quin
etc.
[SP] <number> R)epl A)ccept I)nsert L)ookup U)ncap Q)uit e(X)it or ? for help

Note the toolbar at the bottom of the screen. Since the correct spelling has been offered, if you press "r," then "1," and Enter, "quik" will be replaced with "quick," and ispell will move on to the next misspelled word. When you are finished, type "x" to save your changes; if you decide that you preferred your misspellings, use "q" to exit without saving the changes.

You can also add words to the ispell dictionary; this is most useful for acronyms or personal names. To do this, press "i" to insert into the dictionary. These inserts will be stored in a file in your home directory called .ispell_english. To find about the other useful features of ispell, use the "?" while in ispell, or read its manpage.

Although ispell is easy to use, it won't catch all of your misspellings. If I was a really terrible speller and had written this line in the typos file:

This is a veery kwik file 

ispell would bypass the word "veery" completely and only offer the word "kaik" as a substitute for "kwik".

Let's try aspell on this file. Again, as root and while connected to the Internet, type:

cd /usr/ports/textproc/aspell
make && make install

Don't forget to leave the superuser account and cd back to your home directory when you are finished. Let's quickly overwrite that typos file with the > redirector:

cd
cat > typos
This is a veery kwik file.
^d

The syntax to use aspell is a little longer than ispell; don't forget the word check, or you'll receive a syntax error.

aspell check typos
This is a *veery* kwik file.
1) very             6) veers
2) veer             7) weary
3) Vera             8) every
4) vary             9) verier
5) leery            0) were
i) ignore           I) Ignore all
r) Replace          R) Replace all
a) Add              x) Exit
?

Note that the misspelled word is in asterisks instead of highlighted; it did catch the word "veery" that ispell missed. Also, instead of a menubar at the bottom, the actions are mixed in with the possible spelling options. If we were to continue spell checking this file, aspell would also give a viable alternative to the word "kwik".

Usually I would tell you to read the manpage for aspell to see all of its features, but it does not have one. Instead, you'll have to:

cd /usr/local/share/doc/aspell/man-html

to find its documentation. You could then open up the file manual.html in your favorite web browser and follow the hyperlinks. The manual is well worth browsing, especially if you would like to integrate aspell into your e-mail reader.

In next week's article, we'll take a look at the Webmin utility found in the ports collection.

Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.


Read more FreeBSD Basics columns.

Discuss this article in the Operating Systems Forum.

Return to the BSD DevCenter.

 





Sponsored by: