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

📄 243-246.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Linux Unleashed, Third Edition:tcsh3</TITLE>

<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0672313723//-->

<!--TITLE=Linux Unleashed, Third Edition//-->

<!--AUTHOR=Tim Parker//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Sams//-->

<!--CHAPTER=13//-->

<!--PAGES=243-246//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="../ch12/239-242.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="246-248.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 13<BR>tcsh3

</FONT></H2>

<P><I>by Rick McMullin</I></P>

<DL>

<DT><B>In This Chapter</B>

<DT>&#149;&nbsp;&nbsp; An introduction to tcsh

<DT>&#149;&nbsp;&nbsp; Command completion

<DT>&#149;&nbsp;&nbsp; Command history

<DT>&#149;&nbsp;&nbsp; Input and output redirection

<DT>&#149;&nbsp;&nbsp; Pipelines

<DT>&#149;&nbsp;&nbsp; Prompts

<DT>&#149;&nbsp;&nbsp; Job control

<DT>&#149;&nbsp;&nbsp; Key bindings

<DT>&#149;&nbsp;&nbsp; Other neat stuff

<DT>&#149;&nbsp;&nbsp; Customizing tcsh

<DT>&#149;&nbsp;&nbsp; tcsh command summary

<DT>&#149;&nbsp;&nbsp; tcsh variables

</DL>

<P>The last two chapters introduced you to the Bourne Again Shell (<TT>bash</TT>) and the Public Domain Korn Shell (<TT>pdksh</TT>). This chapter introduces a third shell, <TT>tcsh</TT>. In addition to these topics, we will see how you can customize <TT>tcsh</TT> to suit your tastes. You will also be introduced to several important <TT>tcsh</TT> commands and variables.</P>

<P>Rounding out the chapter is a section on several neat little features that <TT>tcsh</TT> provides that are not available in any of the other shell programs we have discussed.</P>

<H3><A NAME="Heading2"></A><FONT COLOR="#000077">An Introduction to tcsh</FONT></H3>

<P><TT>tcsh</TT> is a modified version of the C shell (<TT>csh</TT>). It is fully backward-compatible with <TT>csh</TT>, but it contains many new features that make user interaction much easier. The biggest improvements over the <TT>csh</TT> are in the areas of command-line editing and history navi-gation.</P>

<H3><A NAME="Heading3"></A><FONT COLOR="#000077">Command Completion</FONT></H3>

<P>Just like <TT>pdksh</TT> and <TT>bash</TT>, <TT>tcsh</TT> supports command-line completion. You invoke command-line completion in <TT>tcsh</TT> exactly the same way that you do in <TT>bash</TT>: by pressing the Tab key at any point while you type a command.</P>

<P>When you press the Tab key, <TT>tcsh</TT> tries to complete the command by matching what has been typed with any file in the directory that the command is referring to. For example, let&#146;s say that you type the following command and then press the Tab key:</P>

<!-- CODE SNIP //-->

<PRE>

emacs hello

</PRE>

<!-- END CODE SNIP //-->

<P>Here, <TT>tcsh</TT> tries to match the letters <TT>hello</TT> with any file (or subdirectory) in the current directory. If there is a single file in the current directory that begins with the letters <TT>hello</TT>, <TT>tcsh</TT> fills in the rest of the filename for you. Now let&#146;s see what happens when you type the following command and then press the Tab key:</P>

<!-- CODE SNIP //-->

<PRE>

emacs /usr/bin/hello

</PRE>

<!-- END CODE SNIP //-->

<P>In this case, <TT>tcsh</TT> will try to match the letters <TT>hello</TT> with any file in the <TT>/usr/bin</TT> directory. From these examples, you can see that you must give <TT>tcsh</TT> something to go on before asking it to complete the command for you.</P>

<P>Another example of using command-line completion is as follows: Assume that the directory that you are currently in contains these files:</P>

<!-- CODE SNIP //-->

<PRE>

News/ bin/ mail/ sample.txt testfile ttd.txt

</PRE>

<!-- END CODE SNIP //-->

<P>If you want to print the <TT>sample.txt</TT> file, type the following command:</P>

<!-- CODE SNIP //-->

<PRE>

lpr sample.txt

</PRE>

<!-- END CODE SNIP //-->

<P>Using command-line completion, you can get away with typing the following command and then pressing the Tab key:

</P>

<!-- CODE SNIP //-->

<PRE>

lpr s

</PRE>

<!-- END CODE SNIP //-->

<P>At this point, <TT>tcsh</TT> attempts to complete the command and finds that the only file that can possibly match what was typed so far is the <TT>sample.txt</TT> file. <TT>tcsh</TT> then completes the command by putting the following text on the command line:</P>

<!-- CODE SNIP //-->

<PRE>

lpr sample.txt

</PRE>

<!-- END CODE SNIP //-->

<P>You can now either confirm that this is the intended command by pressing the Enter key, or you can edit the command if it isn&#146;t the one that you want. Be careful using these shortcuts with some commands, notably <TT>rm</TT>, as you may end up deleting more files than you intended!</P>

<H4 ALIGN="LEFT"><A NAME="Heading4"></A><FONT COLOR="#000077">Wildcards</FONT></H4>

<P><TT>tcsh</TT> enables you to use wildcards in your commands. It supports the same three wildcards as <TT>bash</TT> and <TT>pdksh</TT>:</P>

<DL>

<DD><TT>*</TT> matches any character or any number of characters.

<DD><TT>?</TT> matches any single character.

<DD><TT>[&#133;]</TT> matches any single character contained within the brackets.

</DL>

<P>The <TT>*</TT> wildcard can be used to perform some of the same functions as command-line completion. If you enter a command like</P>

<!-- CODE SNIP //-->

<PRE>

cd t*

</PRE>

<!-- END CODE SNIP //-->

<P>and only one subdirectory in the current directory begins with the letter t, this command behaves the same as if you had used command-line completion by pressing the Tab key.

</P>

<P>The <TT>*</TT> matches any character or any number of characters, so the shell replaces the <TT>t*</TT> with the file in the directory that matches the wildcard pattern.</P>

<P>This works reliably only if there is one file in the directory that starts with the letter &#147;t&#148;. If more than one file in the directory starts with the letter &#147;t&#148;, the shell tries to replace <TT>t*</TT> with the list of filenames in the directory that match the wildcard pattern, and the <TT>cd</TT> command makes the first directory in this list the working directory. This ends up being the file that comes first alphabetically and may or may not be the intended file.</P>

<P>A case that is more suited to using the <TT>*</TT> wildcard is if you want to perform the same operation on a number of files that have similar filenames. For example, assume the current directory contains the following files:</P>

<!-- CODE SNIP //-->

<PRE>

Mail/ atc1.stk atc2.stk bin/ borl.stk cdrom.txt lfi.stk temp/

</PRE>

<!-- END CODE SNIP //-->

<P>If you want to print both of the files that start with <TT>atc</TT> and end with the <TT>.stk</TT> extension, you can do so by typing</P>

<!-- CODE SNIP //-->

<PRE>

lpr a*.stk

</PRE>

<!-- END CODE SNIP //-->

<P>This command will do the job because there are no other files in the directory that start with the letter &#147;a&#148; and have the <TT>.stk</TT> extension.</P>

<P>Using the <TT>?</TT> wildcard, the following command accomplishes the same thing:</P>

<!-- CODE SNIP //-->

<PRE>

lpr atc?.stk

</PRE>

<!-- END CODE SNIP //-->

<P>Using the <TT>[&#133;]</TT> wildcard, you can enter the following command to get the same files to print:</P>

<!-- CODE SNIP //-->

<PRE>

lpr atc[12].stk

</PRE>

<!-- END CODE SNIP //-->

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="../ch12/239-242.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="246-248.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

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