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

📄 ch09_08.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 9] 9.8 Filename Completion: Faster Filename Typing </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:35:01Z"><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="ch09_01.htm"TITLE="9. Saving Time on the Command Line"><LINKREL="prev"HREF="ch09_07.htm"TITLE="9.7 String Editing in ksh and bash "><LINKREL="next"HREF="ch09_09.htm"TITLE="9.9 Don't Match Useless Files in Filename Completion "></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="ch09_07.htm"TITLE="9.7 String Editing in ksh and bash "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 9.7 String Editing in ksh and bash "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 9<BR>Saving Time on the Command Line</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch09_09.htm"TITLE="9.9 Don't Match Useless Files in Filename Completion "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 9.9 Don't Match Useless Files in Filename Completion "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-1210">9.8 Filename Completion: Faster Filename Typing </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="UPT-ART-1210-IX-FILENAMES-COMPLETION"></A><ACLASS="indexterm"NAME="UPT-ART-1210-IX-COMPLETION-FILENAME"></A>If you hate typing long filenames, you should know about the shells'&quot;filename completion&quot; feature.It varies shell-to-shell, so we'll give an overview here.Check the manpage or the shell's Nutshell Handbook for details.</P><PCLASS="para">You can type the initial part of a filename, and then press theTAB key (in the C shell, use ESC).If the shell can figure out the complete filename from the part thatyou've typed, it will fill in the rest of the name. If not, it willfill in as much of the name as is unambiguous, and then let you type somemore.(To enable this in most C shells, set the variable<SPANCLASS="link"><EMCLASS="emphasis">filec</EM> (<ACLASS="linkend"HREF="ch06_09.htm"TITLE="Special C Shell Variables ">6.9</A>)</SPAN>or <EMCLASS="emphasis">complete</EM>.Older C shells don't have this feature.)For example:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">&#13;$ <CODECLASS="userinput"><B>ls</B></CODE>alpha.c    alpha.o   beta.c$ <CODECLASS="userinput"><B>cc b</B></CODE> <KBDCLASS="keycap">[TAB]</KBD><CODECLASS="literal">$ cc beta.c</CODE><ICLASS="lineannotation">Shell fills in the filename automatically</I></PRE></BLOCKQUOTE></P><PCLASS="para">(With <EMCLASS="emphasis">tcsh</EM> and <EMCLASS="emphasis">csh</EM>,your terminal will beep if more than one file matchesthe name you've typed. If all this beeping drives you crazy, you can set the<EMCLASS="emphasis">nobeep</EM> shell variable; that will turn it off.)In thiscase, only one filename begins with <EMCLASS="emphasis">b</EM>, sothe shell can fill in the entire name.</P><PCLASS="para">If you type part of a filename and then type CTRL-d(in <EMCLASS="emphasis">bash</EM>, type TAB twice),the shell lists all the files that match whatever you've typed. It thenredisplays your command line and lets you continue typing.For example:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>cc a</B></CODE><KBDCLASS="keycap">[CTRL-d]</KBD><CODECLASS="literal">alpha.c    alpha.o</CODE>% cc alpha.</PRE></BLOCKQUOTE></P><PCLASS="para">Two files begin with the letter &quot;a&quot;; the shell lists them.It then redisplays the <EMCLASS="emphasis">cc</EM> command, letting you finish thefilename.</P><BLOCKQUOTECLASS="note"><PCLASS="para"><STRONG>NOTE:</STRONG> Also, be forewarned that filename completion is a hack and doesn'talways work correctly.For example: if you're using SunOS, youcan't use filename completion within a &quot;command tool&quot; (SunOS 4.1).Don't try to mix filenamecompletion with wildcards; it won't work.We can't go into detail about these roughedges, but if you're aware thatthey exist, you won't have trouble.</P></BLOCKQUOTE><PCLASS="para">Article<ACLASS="xref"HREF="ch14_09.htm"TITLE="cd by Directory Initials ">14.9</A>shows an interesting shortcut to filename completion: <EMCLASS="emphasis">cd</EM>ing to adirectory by typing its &quot;initials.&quot;</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">ML</SPAN>, <SPANCLASS="authorinitials">JP</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="ch09_07.htm"TITLE="9.7 String Editing in ksh and bash "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 9.7 String Editing in ksh and bash "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="ch09_09.htm"TITLE="9.9 Don't Match Useless Files in Filename Completion "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 9.9 Don't Match Useless Files in Filename Completion "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">9.7 String Editing in ksh and bash </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">9.9 Don't Match Useless Files in Filename Completion </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 + -