⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch29_02.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 29] 29.2 Check Spelling Interactively with ispell </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:45:00Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch29_01.htm"TITLE="29. Spell Checking, Word Counting, and Textual Analysis"><LINKREL="prev"HREF="ch29_01.htm"TITLE="29.1 The UNIX spell Command "><LINKREL="next"HREF="ch29_03.htm"TITLE="29.3 How Do I Spell That Word? "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch29_01.htm"TITLE="29.1 The UNIX spell Command "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 29.1 The UNIX spell Command "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 29<BR>Spell Checking, Word Counting, and Textual Analysis</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch29_03.htm"TITLE="29.3 How Do I Spell That Word? "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 29.3 How Do I Spell That Word? "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-4091">29.2 Check Spelling Interactively with ispell </A></H2><PCLASS="para">The original UNIX spell checking program,<ACLASS="indexterm"NAME="AUTOID-31836"></A><ACLASS="indexterm"NAME="AUTOID-31838"></A><ACLASS="indexterm"NAME="AUTOID-31841"></A><SPANCLASS="link"><EMCLASS="emphasis">spell</EM> (<ACLASS="linkend"HREF="ch29_01.htm#UPT-ART-4080"TITLE="The UNIX spell Command ">29.1</A>)</SPAN>,is fine for quick checks of spelling in a short document, but itmakes you cry out for a real spelling checker, which not onlyshows you the misspelled words in context, but offers to change themfor you.</P><TABLECLASS="para.programreference"BORDER="1"><TR><THVALIGN="TOP"><ACLASS="programreference"HREF="examples/index.htm"TITLE="ispell">ispell</A><BR></TH><TDVALIGN="TOP"><EMCLASS="emphasis">ispell</EM>, a very useful program that's been ported to UNIX andenhanced over the years, does all this and more.Here's the basic usage.</TD></TR></TABLE><PCLASS="para">Just as with <EMCLASS="emphasis">spell</EM>, you spell check a document by giving<EMCLASS="emphasis">ispell</EM> a filename.But there the similarities cease.<EMCLASS="emphasis">ispell</EM> takes over your screen or window, printing two lines ofcontext at the bottom of the screen.If your terminal can do reversevideo, the offending word is highlighted.Several alternatepossibilities are presented in the upper-left corner of the screen&nbsp;- anyword in <EMCLASS="emphasis">ispell</EM>'s dictionary that differs by only one letter, hasa missing or extra letter, or transposed letters.</P><PCLASS="para">Faced with a highlighted word, you have eight choices:</P><DLCLASS="variablelist"><DTCLASS="term"><BCLASS="emphasis.bold">SPACE</B></DT><DDCLASS="listitem"><PCLASS="para">Press the spacebar to accept the current spelling.</P></DD><DTCLASS="term"><BCLASS="emphasis.bold">A</B></DT><DDCLASS="listitem"><PCLASS="para">Type <CODECLASS="literal">A</CODE> to accept the current spelling, now and for therest of this input file. </P></DD><DTCLASS="term"><BCLASS="emphasis.bold">I</B></DT><DDCLASS="listitem"><PCLASS="para">Type <CODECLASS="literal">I</CODE> to accept the current spelling now and for the rest ofthis input file, and also instruct <EMCLASS="emphasis">ispell</EM> toadd the word to your private dictionary.By default, the private dictionary is thefile <EMCLASS="emphasis">.ispell_words</EM> in your home directory, but can be changedwith the <EMCLASS="emphasis">-p</EM> option orby setting the<SPANCLASS="link">environment variable (<ACLASS="linkend"HREF="ch06_01.htm#UPT-ART-1170"TITLE="What Environment Variables Are Good For ">6.1</A>)</SPAN><EMCLASS="emphasis">WORDLIST</EM> to the name ofsome other file.If you work with computers, this option will comein handy, since we use so much jargon in this business!It makes alot more sense to &quot;teach&quot; all those words to <EMCLASS="emphasis">ispell</EM> than tokeep being offered them for possible correction.(One gotcha: when specifying an alternate file, youmust use an <SPANCLASS="link">absolute pathname (<ACLASS="linkend"HREF="ch01_19.htm"TITLE="The Tree Structure of the Filesystem ">1.19</A>)</SPAN>or <EMCLASS="emphasis">ispell</EM> will look for the file in your home directory.)</P></DD><DTCLASS="term"><BCLASS="emphasis.bold">0-9</B></DT><DDCLASS="listitem"><PCLASS="para">Type the digit corresponding to one of <EMCLASS="emphasis">ispell</EM>'s alternativesuggestions to use that spelling instead.For example, if you'vetyped &quot;hnadle,&quot; as I did when writing this article, <EMCLASS="emphasis">ispell</EM> willoffer <CODECLASS="literal">0:&nbsp;handle</CODE> in the upper-left corner of your screen.Typing <CODECLASS="literal">0</CODE> makes the change and moves on to the nextmisspelling, if any.</P></DD><DTCLASS="term"><BCLASS="emphasis.bold">R</B></DT><DDCLASS="listitem"><PCLASS="para">Type <CODECLASS="literal">R</CODE> if none of <EMCLASS="emphasis">ispell</EM>'s offerings do the trick, andyou want to be prompted for a replacement.Type in the new word, andthe replacement is made.</P></DD><DTCLASS="term"><BCLASS="emphasis.bold">L</B></DT><DDCLASS="listitem"><PCLASS="para">Type <CODECLASS="literal">L</CODE> if <EMCLASS="emphasis">ispell</EM> didn't make any helpful suggestions,and you're at a loss how to spell the word correctly.<EMCLASS="emphasis">ispell</EM>will prompt you for a lookup string.You can use <CODECLASS="literal">*</CODE> as a wildcardcharacter (it appears to substitute for zero or one characters);<EMCLASS="emphasis">ispell</EM> will print a list of matching words from itsdictionary.</P></DD><DTCLASS="term"><BCLASS="emphasis.bold">Q</B></DT><DDCLASS="listitem"><PCLASS="para">Type <CODECLASS="literal">Q</CODE> to quit, writing any changes made so far, but ignoring anymisspellings later in the input file.</P></DD><DTCLASS="term"><BCLASS="emphasis.bold">X</B></DT><DDCLASS="listitem"><PCLASS="para">Type <CODECLASS="literal">X</CODE> to quit without writing any changes.</P></DD></DL><PCLASS="para">But that's not all!<EMCLASS="emphasis">ispell</EM> also saves a copy of your originalfile with a <EMCLASS="emphasis">.bak</EM> extension, just in case you regret any of yourchanges.(This is starting to sound like a Ginsu knife commercial!)If you don't want <EMCLASS="emphasis">ispell</EM> making <EMCLASS="emphasis">.bak</EM> files, invoke it with the<EMCLASS="emphasis">-x</EM> option.</P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-31926"></A><ACLASS="indexterm"NAME="AUTOID-31929"></A>How about this: <EMCLASS="emphasis">ispell</EM> knows about capitalization.It alreadyknows about proper names and a lot of common acronyms&nbsp;- it can evenhandle words  like &quot;TeX&quot; that have oddball capitalization.Speakingof<SPANCLASS="link">TeX (<ACLASS="linkend"HREF="ch43_12.htm"TITLE="Typesetting Overview ">43.12</A>)</SPAN>,it even has a special mode in which it recognizes TeX constructions.(Too bad <EMCLASS="emphasis">ispell</EM> doesn't know about<SPANCLASS="link"><EMCLASS="emphasis">troff</EM> (<ACLASS="linkend"HREF="ch43_13.htm"TITLE="The Text Formatters nroff, troff, ditroff, ... ">43.13</A>)</SPAN>.)</P><PCLASS="para">For even more features, see the manual pages stored with the programon the disc.</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">TOR</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch29_01.htm"TITLE="29.1 The UNIX spell Command "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 29.1 The UNIX spell Command "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch29_03.htm"TITLE="29.3 How Do I Spell That Word? "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 29.3 How Do I Spell That Word? "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">29.1 The UNIX spell Command </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">29.3 How Do I Spell That Word? </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed &amp; awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -