📄 ch05_03.htm
字号:
can be expanded to its full name when the Escape key is pressed. If more than one filename matches, type <em class="emphasis">EOF</em> to list possible completions.</p></td></tr><tr><td><tt class="literal">hardpaths</tt></td><td><p>Tell <tt class="literal">dirs</tt> to display the actual pathname<a name="IXT-5-122938" />of any directory that is a symbolic link.</p></td></tr><tr><td><tt class="literal">histchars=</tt><em class="replaceable"><tt>ab</tt></em></td><td><p>A two-character string that sets the characters to use<a name="IXT-5-122939" />in history-substitution and quick-substitution (default is <tt class="literal">!^</tt>).</p></td></tr><tr><td><tt class="literal">history=</tt><em class="replaceable"><tt>n</tt></em></td><td><p><a name="IXT-5-122940" />Number of commands to save in history list.</p></td></tr><tr><td><tt class="literal">home=</tt><em class="replaceable"><tt>dir</tt></em></td><td><p>Home directory of user, initialized from HOME. <a name="IXT-5-122941" />The <tt class="literal">~</tt> character is shorthand for this value.</p></td></tr><tr><td><tt class="literal">ignoreeof</tt></td><td><p><a name="IXT-5-122942" />Ignore an end-of-file (<em class="emphasis">EOF</em>) from terminals;prevents accidental logout.</p></td></tr><tr><td><tt class="literal">mail=(</tt><em class="replaceable"><tt>n file</tt></em><tt class="literal">)</tt></td><td><p><a name="IXT-5-122943" />One or more files checked for new mail every five minutes or(if <em class="emphasis">n</em> is supplied) every <em class="emphasis">n</em> seconds.</p></td></tr><tr><td><tt class="literal">nobeep</tt></td><td><p><a name="IXT-5-122944" />Don't ring bell for ambiguous file completion (see <tt class="literal">filec</tt>).</p></td></tr><tr><td><tt class="literal">noclobber</tt></td><td><p>Don't redirect output to an existing file; prevents accidental<a name="IXT-5-122945" />destruction of files.</p></td></tr><tr><td><tt class="literal">noglob</tt></td><td><p><a name="IXT-5-122946" />Turn off filename expansion; useful in shell scripts.</p></td></tr><tr><td><tt class="literal">nonomatch</tt></td><td><p><a name="IXT-5-122947" />Treat filename metacharacters as literal characters;e.g., <tt class="literal">vi ch*</tt> creates new file <tt class="literal">ch*</tt> instead of printing “No match.”</p></td></tr><tr><td><tt class="literal">notify</tt></td><td><p>Notify user of completed jobs right away,<a name="IXT-5-122948" />instead of waiting for the next prompt.</p></td></tr><tr><td><tt class="literal">path=(</tt><em class="replaceable"><tt>dirs</tt></em><tt class="literal">)</tt></td><td><p> List of pathnames in which to search for commands to execute. Initialized from PATH. SVR4 default is <tt class="literal">( . /usr/ucb /usr/bin )</tt>. On Solaris, the default path is <tt class="literal">( /usr/bin . )</tt>. However, the standard start-up scripts then change it to <tt class="literal">( /bin /usr/bin /usr/ucb /etc . )</tt>. </p></td></tr><tr><td><tt class="literal">prompt='</tt><em class="replaceable"><tt>str</tt></em><tt class="literal">'</tt></td><td><p><a name="IXT-5-122949" />String that prompts for interactive input;default is <tt class="literal">%</tt>. </p></td></tr><tr><td><tt class="literal">savehist=</tt><em class="replaceable"><tt>n</tt></em></td><td><p>Number of history commands to save in<a name="IXT-5-122950" /><tt class="literal">~/.history</tt> upon logout; they can be accessedat the next login.</p></td></tr><tr><td><tt class="literal">shell=</tt><em class="replaceable"><tt>file</tt></em></td><td><p>Pathname of the shell program currently in use;default is <tt class="literal">/bin/csh</tt>.<a name="IXT-5-122951" /></p></td></tr><tr><td><tt class="literal">status=</tt><em class="replaceable"><tt>n</tt></em></td><td><p>Exit status of last command. Built-in commands return<a name="IXT-5-122952" />0 (success) or 1 (failure).</p></td></tr><tr><td><tt class="literal">term=</tt><em class="replaceable"><tt>ID</tt></em></td><td><p>Name of terminal type,same as TERM.<a name="IXT-5-122953" /></p></td></tr><tr><td><tt class="literal">time='</tt><em class="replaceable"><tt>n</em> <tt class="literal">%</tt><em class="replaceable">c</em><tt class="literal">'</tt></td><td><p>If command execution takes more than <em class="emphasis">n</tt></em> CPU seconds,<a name="IXT-5-122954" />report user time, system time, elapsed time, and CPU percentage.Supply optional <tt class="literal">%</tt><em class="emphasis">c</em> flags to show other data.</p></td></tr><tr><td><tt class="literal">user=</tt><em class="replaceable"><tt>name</tt></em></td><td><p>Login name of user, initialized from USER.<a name="IXT-5-122955" /></p></td></tr><tr><td><tt class="literal">verbose</tt></td><td><p>Display a command after history substitution; same as the <a name="IXT-5-122956" />command <tt class="literal">csh -v</tt>.</p></td></tr></table><p></div><a name="unut-ch-5-sect-3.4" /><div class="sect2"><h3 class="sect2">5.3.4. Example .cshrc File</h3><p><a name="IXT-5-122957" /></p><blockquote><pre class="code"># PREDEFINED VARIABLESset path=(~ ~/bin /usr/ucb /bin /usr/bin . )set mail=(/var/mail/tom)if ($?prompt) then # Settings for interactive use set echo set filec set noclobber ignoreeof set cdpath=(/usr/lib /var/spool/uucp)# Now I can type cd macros # instead of cd /usr/lib/macros set fignore=.o # Ignore object files for filec set history=100 savehist=25 set prompt='tom \!% ' # Includes history number set time=3# MY VARIABLES set man1="/usr/man/man1" # Lets me do cd $man1, ls $man1 set a="[a-z]*" # Lets me do vi $a set A="[A-Z]*" # Or grep string $A# ALIASES alias c "clear; dirs" # Use quotes to protect ; or | alias h "history | more" alias j jobs -l alias ls ls -sFC # Redefine ls command alias del 'mv \!* ~/tmp_dir'# A safe alternative to rmendif</pre></blockquote></div><a name="unut-ch-5-sect-3.5" /><div class="sect2"><h3 class="sect2">5.3.5. Environment Variables</h3><p><a name="IXT-5-122958" /><a name="IXT-5-122959" />The C shell maintains a set of <em class="emphasis">environment variables</em>,which are distinct from shell variables and aren't really part of the C shell.Shell variables are meaningful only within the current shell, butenvironment variables are automatically exported,making them available globally.For example, C shell variables are accessible only to a particular script in which they're defined, whereasenvironment variables can be usedby any shell scripts, mail utilities, or editors you might invoke.</p><p>Environment variables are assigned as follows:</p><blockquote><pre class="code">setenv <em class="replaceable"><tt>VAR value</tt></em></pre></blockquote><p>By convention, environment variable names are all uppercase.You can create your own environment variables,or you can use the following predefined environment variables.</p><p>These environment variables have a corresponding C shell variable:</p><dl><dt><i>HOME</i></dt><dd><a name="IXT-5-122960" />Home directory; same as <tt class="literal">home</tt>.These may be changed independently of each other.</p></dd><dt><i>PATH</i></dt><dd><a name="IXT-5-122961" />Search path for commands; same as <tt class="literal">path</tt>.Changing either one updates the value stored in the other.</p></dd><dt><i>TERM</i></dt><dd><a name="IXT-5-122962" />Terminal type; same as <tt class="literal">term</tt>.Changing <tt class="literal">term</tt> updates TERM, but notthe other way around.</p></dd><dt><i>USER</i></dt><dd><a name="IXT-5-122963" />Username; same as <tt class="literal">user</tt>.Changing <tt class="literal">user</tt> updates USER, but notthe other way around.</p></dd></dl><p>Other environment variables include the following:</p><dl><dt><i>EXINIT</i></dt><dd>A string of <tt class="literal">ex</tt> commands similar to those found in<a name="IXT-5-122964" />the startup <tt class="literal">.exrc</tt> file (e.g., <tt class="literal">set ai</tt>).Used by <tt class="literal">vi</tt> and <tt class="literal">ex</tt>.</p></dd><dt><i>LOGNAME</i></dt><dd><a name="IXT-5-122965" />Another name for the USER variable.</p></dd><dt><i>MAIL</i></dt><dd>The file that holds mail. Used by mail programs.<a name="IXT-5-122966" />This is not the same as the C shell <tt class="literal">mail</tt> variable,which only checks for new mail.</p></dd><dt><i>PWD</i></dt><dd><a name="IXT-5-122967" />The current directory; the value is copied from <tt class="literal">cwd</tt>.</p></dd><dt><i>SHELL</i></dt><dd>Undefined by default; once initialized to <tt class="literal">shell</tt>,<a name="IXT-5-122968" />the two are identical.</p></dd></dl><a name="IXT-5-122969" /><a name="IXT-5-122970" /></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch05_02.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch05_04.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">5.2. Syntax</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">5.4. Expressions</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright © 2003</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,88,96" href="../index.htm"><area shape="rect" coords="90,0,165,96" href="../upt/index.htm"><area shape="rect" coords="168,1,253,107" href="../mac/index.htm"><area shape="rect" coords="255,0,335,97" href="../korn/index.htm"><area shape="rect" coords="337,0,415,109" href="../unixnut/index.htm"><area shape="rect" coords="417,0,512,122" href="../sedawk/index.htm"><area shape="rect" coords="514,0,605,105" href="../lunix/index.htm"><area shape="rect" coords="611,2,694,121" href="../vi/index.htm"></map></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -