📄 unx28.htm
字号:
<HTML>
<HEAD>
<TITLE>UNIX Unleashed unx28.htm</TITLE>
<LINK REL="ToC" HREF="index.htm">
<LINK REL="Next" HREF="unx29.htm">
<LINK REL="Previous" HREF="unx27.htm"></HEAD>
<BODY TEXT="#000000" LINK="#0000FF" VLINK="#800080" bgcolor=white>
<P><A HREF="unx27.htm"><IMG SRC="bluprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>
<A HREF="index.htm"><IMG SRC="blutoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>
<A HREF="unx29.htm"><IMG SRC="blunext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>
<A HREF="index.htm"><IMG SRC="bluprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Home"></A>
</P><UL>
<LI>
<A HREF="#I1">28</A></LI>
<UL>
<LI>
<A HREF="#I3">Tools for Writers</A></LI>
<UL>
<UL>
<UL>
<LI>
<A HREF="#I4">By Susan Peppard</A></LI></UL></UL>
<LI>
<A HREF="#I5">Using spell</A></LI>
<UL>
<LI>
<A HREF="#I6">Creating a Personal Dictionary</A></LI>
<LI>
<A HREF="#I7">Creating Specialized Dictionaries</A></LI>
<LI>
<A HREF="#I8">Using ispell</A></LI>
<LI>
<A HREF="#I9">/dev/null: The Path to UNIX Limbo</A></LI></UL>
<LI>
<A HREF="#I10">Countoing Words with wc</A></LI>
<LI>
<A HREF="#I11">Using grep</A></LI>
<UL>
<LI>
<A HREF="#I12">Checking the Organization of a Document</A></LI>
<LI>
<A HREF="#I13">Finding Character Strings</A></LI></UL>
<LI>
<A HREF="#I14">Using sed</A></LI>
<LI>
<A HREF="#I15">Using diffmk</A></LI>
<LI>
<A HREF="#I16">The man Command</A></LI>
<LI>
<A HREF="#I17">Using SCCS to Control Documentation</A></LI></UL></UL></UL>
<H1 ALIGN="CENTER">
<CENTER><A ID="I1" NAME="I1">
<BR>
<FONT SIZE=5><A ID="I2" NAME="I2"></A><B>28</B>
<BR></FONT></A></CENTER></H1>
<H2 ALIGN="CENTER">
<CENTER><A ID="I3" NAME="I3">
<FONT SIZE=5><B>Tools for Writers</B>
<BR></FONT></A></CENTER></H2>
<H5 ALIGN="CENTER">
<CENTER><A ID="I4" NAME="I4">
<FONT SIZE=3><B>By Susan Peppard</B>
<BR></FONT></A></CENTER></H5>
<H3 ALIGN="CENTER">
<CENTER><A ID="I5" NAME="I5">
<FONT SIZE=4><B>Using </B><B><I>spell</I></B>
<BR></FONT></A></CENTER></H3>
<P>You've gone to a lot of trouble to prepare a document that looks splendid and you don't want it to be marred by spelling mistakes. The spell program will catch most of your typos. An interactive version of spell, called ispell, also is available on some
systems.
<BR></P>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="note.gif" WIDTH = 35 HEIGHT = 35><B>NOTE:</B> spell will not find errors such as is for in or affect for effect. You still have to proofread your document carefully.
<BR></NOTE>
<HR ALIGN=CENTER>
<P>spell uses a standard dictionary. It checks the words in your file against this dictionary and outputs a list of words not found in the dictionary. You can create a personal dictionary to make spell more useful, as you'll learn in the next section.
<BR></P>
<P>If your file includes .sos or .nxs, spell searches the sourced in files.
<BR></P>
<P>To invoke spell, type spell and your filename. All the words that spell doesn't recognize are displayed on your screen, one word per line. This list of unrecognized words is arranged in ASCII order. That is, special characters and numbers come first,
uppercase letters come next, and then lowercase letters. In other words, the words are not in the order in which they occur in your file. Each unrecognized word appears only once. Therefore, if you typed teh for the 15 times, teh appears only once in the
spell output.
<BR></P>
<P>The list of unrecognized words can be very long, especially if your text is full of acronyms or proper names or if you don't type well. The first few screens will speed by at what seems like 1,000 miles per hour, and you won't be able to read them at
all. To read all the screens, redirect the output of spell to a file:
<BR></P>
<PRE>$ spell filename > outputfilename</PRE>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP:</B> Use a short name for this output file. w—for wrong—works well. You can open a file with a short name more quickly, and delete it more quickly, too. It's also less embarrassing to have a file
called w in all your directories instead of one called misspelled_words.
<BR></NOTE>
<HR ALIGN=CENTER>
<P>After you create the file of unrecognized words, you can handle it in several ways:
<BR></P>
<UL>
<LI>You can print the file.
<BR>
<BR></LI>
<LI>You can vi the file and try to remember the misspellings—or scribble them on a slip of paper.
<BR>
<BR></LI>
<LI>You can vi the file in another window if you are using a window-like environment.
<BR>
<BR></LI></UL>
<P>Now correct your mistakes. The list probably contains a number of words that are perfectly legitimate. For example, spell refuses to recognize the words diskette and detail. There is no good reason for this, but it may spur you to create a personal
dictionary.
<BR></P>
<P>To correct your mistakes, first vi your file. Next, do one of the following:
<BR></P>
<UL>
<LI>Search for the misspelling—/teh—and correct it—cw the. Then search for the next occurrence of teh—n—and correct it with the . command. Continue doing this until the search produces pattern not found.
<BR>
<BR></LI>
<LI>Globally change all occurrences of teh to the—:1, $ s/teh/the/g.
<BR>
<BR></LI></UL>
<P>There's a risk associated with the global method. For example, if I ran spell on this chapter, teh would appear on the list of unrecognized words. Then if I globally changed all occurrences of teh to the, this chapter, or at least this section, would be
virtually incomprehensible. The moral is, use global substitutions wisely, and never use them on someone else's files.
<BR></P>
<P>After you correct your file, run it through spell once more just to be sure. The new output overwrites the old file.
<BR></P>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP:</B> If you're a less-than-perfect typist—or if you have fat fingertips—unwanted characters can sneak into words—for example, p[rint. When this happens, rint appears on spell's list of
unrecognized words. Just search for rint. However, if you type p[lace, spell won't help you, because lace is a perfectly good word.
<BR></NOTE>
<HR ALIGN=CENTER>
<P>Occasionally, spell finds something like ne. Searching for all instances of ne isn't fun, especially in a file with 2,000 lines. You can embed spaces in your search—s/[space]ne[space]. However, this is rarely helpful, because spell ignores
punctuation marks and special characters. If you typed This must be the o ne, s/[space]ne[space], it won't find it. You can try searching with one embedded space—s/[space]ne and s/ne[space]—, but you still may not find the offender. Try
/\<ne\>. This will find ne as a complete word, that is, surrounded by spaces; at the beginning or end of a line; or followed by punctuation.
<BR></P>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP:</B> Even if you added only half a line, run spell once more after you've edited a chapter. You always find a mistake.
<BR></NOTE>
<HR ALIGN=CENTER>
<H4 ALIGN="CENTER">
<CENTER><A ID="I6" NAME="I6">
<FONT SIZE=3><B>Creating a Personal Dictionary</B>
<BR></FONT></A></CENTER></H4>
<P>If your name is Leee—with three es—and you get tired of seeing it in the list of unrecognized words, you can add Leee to a personal dictionary.
<BR></P>
<P>To create a personalized dictionary, follow these steps:
<BR></P>
<OL>
<LI>Create a file called mydict. Of course, you may call it anything you like.
<BR>
<BR></LI>
<LI>Invoke spell with $ spell+mydict inputfile > w.
<BR>
<BR></LI></OL>
<P>Your personal dictionary doesn't have to be in the same directory as your input files. If it isn't, however, you must specify a path on the command line, as in
<BR></P>
<PRE>$ spell+/dict/mydict inputfile > w</PRE>
<H4 ALIGN="CENTER">
<CENTER><A ID="I7" NAME="I7">
<FONT SIZE=3><B>Creating Specialized Dictionaries</B>
<BR></FONT></A></CENTER></H4>
<P>Personalized dictionaries are a great help if you're working on several writing projects, each of which has a specialized vocabulary. For example, if you're working on the XYZZY project, and the same words keep turning up in your w file—words that
are perfectly O.K. in the context of the XYZZY system but not O.K. in any other files—you can create an xyzzy.dict.
<BR></P>
<P>An easy way to automate some of the steps necessary for creating a specialized dictionary is to run spell on your first file. For example,
<BR></P>
<PRE>$ spell ch01 > w</PRE>
<P>Then run it on all the rest of your files. Append the output to w, instead of replacing w. For example,
<BR></P>
<PRE>$ spell ch02 >> w</PRE>
<P>At this point, you'll have a long file that contains all the words that spell doesn't recognize. First, you need to sort the file and get rid of the duplicates. (Refer to the sort command in Chapter 6, "Popular File Tools.")
<BR></P>
<PRE>$ sort w -u>sorted.w</PRE>
<P>Here, the -u option stands for unique. sort drops all the duplicates from the list.
<BR></P>
<P>Now edit sorted.w, deleting all the misspelled words and all words not specific to your XYZZY project. The words that remain form the basis of xyzzy.dict. Change the name of sorted.w to xyzzy.dict by using mv sorted.w xyzzy.dict. You can add words to or
delete words from this file as necessary.
<BR></P>
<P>Repeat this process to create additional specialized dictionaries. And if you're a nice person, you'll share your specialized dictionaries with your colleagues.
<BR></P>
<H4 ALIGN="CENTER">
<CENTER><A ID="I8" NAME="I8">
<FONT SIZE=3><B>Using </B><B><I>ispell</I></B>
<BR></FONT></A></CENTER></H4>
<P>ispell is an interactive version of spell. It works like the spell checkers that come with word processing applications. That is, it locates the first word in your file that it doesn't recognize—ispell uses the same dictionary as spell—and
stops there. Then you can correct the word or press Enter to continue.
<BR></P>
<P>To invoke ispell, do one of the following:
<BR></P>
<UL>
<LI>Enter ispell ch01.
<BR>
<BR></LI>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -