📄 fc.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>fc</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="fc"></a> <a name="tag_04_52"></a><!-- fc --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_04_52_01"></a>NAME</h4><blockquote>fc - process the command history list</blockquote><h4><a name="tag_04_52_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('UP')">UP</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> fc</tt> <b>[</b><tt>-r</tt><b>][</b><tt>-e</tt> <i>editor</i><b>][</b><i>first</i><b>[</b><i>last</i><b>]]</b><tt><br><br>fc -l</tt><b>[</b><tt>-nr</tt><b>] [</b><i>first</i><b>[</b><i>last</i><b>]]</b><tt><br><br>fc -s</tt><b>[</b><i>old</i><tt>=</tt><i>new</i><b>][</b><i>first</i><b>]</b><tt><img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div><tt><br></tt></blockquote><h4><a name="tag_04_52_03"></a>DESCRIPTION</h4><blockquote><p>The <i>fc</i> utility shall list, or shall edit and re-execute, commands previously entered to an interactive <a href="../utilities/sh.html"><i>sh</i></a>.</p><p>The command history list shall reference commands by number. The first number in the list is selected arbitrarily. Therelationship of a number to its command shall not change except when the user logs in and no other process is accessing the list,at which time the system may reset the numbering to start the oldest retained command at another number (usually 1). When thenumber reaches an implementation-defined upper limit, which shall be no smaller than the value in <i>HISTSIZE</i> or 32767(whichever is greater), the shell may wrap the numbers, starting the next command with a lower number (usually 1). However, despitethis optional wrapping of numbers, <i>fc</i> shall maintain the time-ordering sequence of the commands. For example, if fourcommands in sequence are given the numbers 32766, 32767, 1 (wrapped), and 2 as they are executed, command 32767 is considered thecommand previous to 1, even though its number is higher.</p><p>When commands are edited (when the <b>-l</b> option is not specified), the resulting lines shall be entered at the end of thehistory list and then re-executed by <a href="../utilities/sh.html"><i>sh</i></a>. The <i>fc</i> command that caused the editingshall not be entered into the history list. If the editor returns a non-zero exit status, this shall suppress the entry into thehistory list and the command re-execution. Any command line variable assignments or redirection operators used with <i>fc</i> shallaffect both the <i>fc</i> command itself as well as the command that results; for example:</p><pre><tt>fc -s -- -1 2>/dev/null</tt></pre><p>reinvokes the previous command, suppressing standard error for both <i>fc</i> and the previous command.</p></blockquote><h4><a name="tag_04_52_04"></a>OPTIONS</h4><blockquote><p>The <i>fc</i> utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p><p>The following options shall be supported:</p><dl compact><dt><b>-e </b> <i>editor</i></dt><dd>Use the editor named by <i>editor</i> to edit the commands. The <i>editor</i> string is a utility name, subject to search viathe <i>PATH</i> variable (see the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html">Chapter 8, Environment Variables</a>). The value in the <i>FCEDIT</i> variable shall be used as adefault when <b>-e</b> is not specified. If <i>FCEDIT</i> is null or unset, <a href="../utilities/ed.html"><i>ed</i></a> shall beused as the editor.</dd><dt><b>-l</b></dt><dd>(The letter ell.) List the commands rather than invoking an editor on them. The commands shall be written in the sequenceindicated by the <i>first</i> and <i>last</i> operands, as affected by <b>-r</b>, with each command preceded by the commandnumber.</dd><dt><b>-n</b></dt><dd>Suppress command numbers when listing with <b>-l</b>.</dd><dt><b>-r</b></dt><dd>Reverse the order of the commands listed (with <b>-l</b>) or edited (with neither <b>-l</b> nor <b>-s</b>).</dd><dt><b>-s</b></dt><dd>Re-execute the command without invoking an editor.</dd></dl></blockquote><h4><a name="tag_04_52_05"></a>OPERANDS</h4><blockquote><p>The following operands shall be supported:</p><dl compact><dt><i>first</i>, <i>last</i></dt><dd>Select the commands to list or edit. The number of previous commands that can be accessed shall be determined by the value ofthe <i>HISTSIZE</i> variable. The value of <i>first</i> or <i>last</i> or both shall be one of the following: <dl compact><dt><b>[+]</b><i>number</i></dt><dd>A positive number representing a command number; command numbers can be displayed with the <b>-l</b> option.</dd><dt><b>-</b><i>number</i></dt><dd>A negative decimal number representing the command that was executed <i>number</i> of commands previously. For example, -1 isthe immediately previous command.</dd><dt><i>string</i></dt><dd>A string indicating the most recently entered command that begins with that string. If the <i>old</i>= <i>new</i> operand isnot also specified with <b>-s</b>, the string form of the <i>first</i> operand cannot contain an embedded equal sign.</dd></dl><p>When the synopsis form with <b>-s</b> is used:</p><ul><li><p>If <i>first</i> is omitted, the previous command shall be used.</p></li></ul><p>For the synopsis forms without <b>-s</b>:</p><ul><li><p>If <i>last</i> is omitted, <i>last</i> shall default to the previous command when <b>-l</b> is specified; otherwise, it shalldefault to <i>first</i>.</p></li><li><p>If <i>first</i> and <i>last</i> are both omitted, the previous 16 commands shall be listed or the previous single command shallbe edited (based on the <b>-l</b> option).</p></li><li><p>If <i>first</i> and <i>last</i> are both present, all of the commands from <i>first</i> to <i>last</i> shall be edited (without<b>-l</b>) or listed (with <b>-l</b>). Editing multiple commands shall be accomplished by presenting to the editor all of thecommands at one time, each command starting on a new line. If <i>first</i> represents a newer command than <i>last</i>, thecommands shall be listed or edited in reverse sequence, equivalent to using <b>-r</b>. For example, the following commands on thefirst line are equivalent to the corresponding commands on the second:</p><pre><tt>fc -r 10 20 fc 30 40fc 20 10 fc -r 40 30</tt></pre></li><li><p>When a range of commands is used, it shall not be an error to specify <i>first</i> or <i>last</i> values that are not in thehistory list; <i>fc</i> shall substitute the value representing the oldest or newest command in the list, as appropriate. Forexample, if there are only ten commands in the history list, numbered 1 to 10:</p><pre><tt>fc -lfc 1 99</tt></pre><p>shall list and edit, respectively, all ten commands.</p></li></ul></dd><dt><i>old</i>=<i>new</i></dt><dd>Replace the first occurrence of string <i>old</i> in the commands to be re-executed by the string <i>new</i>.</dd></dl></blockquote><h4><a name="tag_04_52_06"></a>STDIN</h4><blockquote><p>Not used.</p></blockquote><h4><a name="tag_04_52_07"></a>INPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_52_08"></a>ENVIRONMENT VARIABLES</h4><blockquote><p>The following environment variables shall affect the execution of <i>fc</i>:</p><dl compact><dt><i>FCEDIT</i></dt><dd>This variable, when expanded by the shell, shall determine the default value for the <b>-e</b> <i>editor</i> option's<i>editor</i> option-argument. If <i>FCEDIT</i> is null or unset, <a href="../utilities/ed.html"><i>ed</i></a> shall be used as theeditor.</dd><dt><i>HISTFILE</i></dt><dd>Determine a pathname naming a command history file. If the <i>HISTFILE</i> variable is not set, the shell may attempt to accessor create a file <b>.sh_history</b> in the directory referred to by the <i>HOME</i> environment variable. If the shell cannotobtain both read and write access to, or create, the history file, it shall use an unspecified mechanism that allows the history tooperate properly. (References to history "file" in this section shall be understood to mean this unspecified mechanism in suchcases.) An implementation may choose to access this variable only when initializing the history file; this initialization shalloccur when <i>fc</i> or <a href="../utilities/sh.html"><i>sh</i></a> first attempt to retrieve entries from, or add entries to, thefile, as the result of commands issued by the user, the file named by the <i>ENV</i> variable, or implementation-defined systemstart-up files. In some historical shells, the history file is initialized just after the <i>ENV</i> file has been processed.Therefore, it is implementation-defined whether changes made to <i>HISTFILE</i> after the history file has been initialized areeffective. Implementations may choose to disable the history list mechanism for users with appropriate privileges who do not set<i>HISTFILE ;</i> the specific circumstances under which this occurs are implementation-defined. If more than one instance of theshell is using the same history file, it is unspecified how updates to the history file from those shells interact. As entries aredeleted from the history file, they shall be deleted oldest first. It is unspecified when history file entries are physicallyremoved from the history file.</dd><dt><i>HISTSIZE</i></dt><dd>Determine a decimal number representing the limit to the number of previous commands that are accessible. If this variable isunset, an unspecified default greater than or equal to 128 shall be used. The maximum number of commands in the history list isunspecified, but shall be at least 128. An implementation may choose to access this variable only when initializing the historyfile, as described under <i>HISTFILE .</i> Therefore, it is unspecified whether changes made to <i>HISTSIZE</i> after the historyfile has been initialized are effective.</dd><dt><i>LANG</i></dt><dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume ofIEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> for
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -