<!DOCTYPE REFENTRY PUBLIC "-//Sun Microsystems//DTD DocBook V3.0-Based SolBook Subset V2.0//EN" [
<!--ArborText, Inc., 1988-1997, v.4001-->
<!ENTITY % commonents SYSTEM "smancommon.ent">
%commonents;
<!ENTITY % booktitles SYSTEM "booktitles.ent">
%booktitles;
]>
<refentry id="history-1">
<!-- @(#)history.1 1.2 98/09/23 SMI; -->
<refmeta><refentrytitle>history</refentrytitle><manvolnum>1</manvolnum>
<refmiscinfo class="date">30 Oct 1995</refmiscinfo>
<refmiscinfo class="sectdesc">&man1;</refmiscinfo>
<refmiscinfo class="software">&release;</refmiscinfo>
<refmiscinfo class="arch">generic</refmiscinfo>
<refmiscinfo class="copyright">Copyright 1989 AT&amp;T</refmiscinfo>
<refmiscinfo class="copyright">Copyright (c) 1995, Sun Microsystems, Inc.  All Rights Reserved</refmiscinfo>
<refmiscinfo class="copyright">Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved</refmiscinfo>
</refmeta>
<refnamediv><refname>history</refname><refname>fc</refname><refpurpose>process command history list</refpurpose></refnamediv>
<refsynopsisdiv><title>&synp-tt;</title>
<cmdsynopsis><command>/usr/bin/fc</command><arg choice="opt"><arg choice="plain"><replaceable>first</replaceable></arg><arg choice="opt"><replaceable>last</replaceable></arg></arg>
</cmdsynopsis>
<cmdsynopsis><command>/usr/bin/fc</command><arg choice="plain"><option>l</option></arg><arg choice="opt"><option>nr</option></arg><arg choice="opt"><arg choice="plain"><replaceable>first</replaceable></arg><arg
choice="opt"><replaceable>last</replaceable></arg></arg>
</cmdsynopsis>
<cmdsynopsis><command>/usr/bin/fc</command><arg choice="plain"><option>s</option></arg><arg choice="opt"><arg choice="plain"><replaceable>old</replaceable></arg><arg choice="plain">=</arg><arg choice="plain"><replaceable>
new</replaceable></arg></arg><arg choice="opt"><replaceable>first</replaceable></arg>
</cmdsynopsis><refsect2><title>csh</title>
<cmdsynopsis><command>history</command><arg choice="opt"><option>hr</option></arg><arg choice="opt"><replaceable>n</replaceable></arg>
</cmdsynopsis></refsect2>
<refsect2><title>ksh</title>
<cmdsynopsis><command>fc</command><arg choice="plain"><option>e</option></arg><arg choice="plain"><option>
<!--Element without content-->
</option></arg><arg choice="opt"><arg choice="plain"><replaceable>old</replaceable></arg><arg choice="plain">=</arg><arg choice="plain"><replaceable>new</replaceable></arg></arg><arg choice="opt"><replaceable>
command</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis><command>fc</command><arg choice="opt"><option>e</option>&nbsp;<replaceable>ename</replaceable></arg><arg choice="opt"><option>nlr</option></arg><arg choice="opt"><arg choice="plain"><replaceable>
first</replaceable></arg><arg choice="opt"><replaceable>last</replaceable></arg></arg>
</cmdsynopsis></refsect2>
</refsynopsisdiv>
<refsect1><title>&desc-tt;</title>
<indexterm significance="normal" id="history-1-indx-1"><primary sortas="history" os="solaris">history &mdash; shell built-in functions to re-use previous command-lines from the current shell</primary></indexterm>
<indexterm significance="normal" id="history-1-indx-2"><primary sortas="fc" os="solaris">fc &mdash; shell built-in functions to re-use previous command-lines from the current shell</primary></indexterm>
<indexterm significance="normal" id="history-1-indx-3"><primary os="solaris">shell command interpreter builtin-functions</primary><secondary sortas="history" os="solaris">&mdash; history</secondary></indexterm>
<indexterm significance="normal" id="history-1-indx-4"><primary os="solaris">shell command interpreter builtin-functions</primary><secondary sortas="fc" os="solaris">&mdash; fc</secondary></indexterm><refsect2>
<title>/usr/bin/fc</title>
<para>The <command>fc</command> utility lists or edits and reexecutes, commands previously entered to an interactive <command>sh</command>.</para>
<para>The command history list references commands by number. The first number in the list is selected arbitrarily. The relationship of a number to its command will 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 the number reaches the value in <literal
remap="small and bold">HISTSIZE</literal> or 128 (whichever is greater), the shell may wrap the numbers, starting the next command with a lower number (usually 1). However, despite this optional wrapping
of numbers, <command>fc</command> will maintain the time-ordering sequence of the commands. For example, if four commands in sequence are given the numbers 32&thinsp;766, 32&thinsp;767, 1 (wrapped), and
2 as they are executed, command 32&thinsp;767 is considered the command previous to 1, even though its number is higher.</para>
<para>When commands are edited (when the <option>l</option> option is not specified), the resulting lines will be entered at the end of the history list and then reexecuted by <command>sh</command>. The <command>
fc</command> command that caused the editing will not be entered into the history list. If the editor returns a non-zero exit status, this will suppress the entry into the history list and the command reexecution.
Any command-line variable assignments or redirection operators used with <command>fc</command> will affect both the <command>fc</command> command itself as well as the command that results, for example:<informalexample>
<screen>fc -s -- -1 2>/dev/null</screen>
</informalexample>reinvokes the previous command, suppressing standard error for both <command>fc</command> and the previous command.</para>
</refsect2>
<refsect2><title>csh</title>
<para>Display the history list; if <replaceable>n</replaceable> is given, display only the <replaceable>n</replaceable> most recent events.</para>
<variablelist termlength="xtranarrow"><varlistentry><term remap="2"><option>r</option> </term><listitem><para>Reverse the order of printout to be most recent first rather than oldest first.</para>
</listitem></varlistentry>
<varlistentry><term><option>h</option> </term><listitem><para>Display the history list without leading numbers. This is used to produce files suitable for sourcing using the <option>h</option> option to
the <command>csh</command> built-in command, <link linkend="source-1"><citerefentry><refentrytitle>source</refentrytitle><manvolnum>1</manvolnum></citerefentry></link>.</para>
</listitem></varlistentry>
</variablelist>
<refsect3><title>History Substitution</title>
<para>History substitution allows you to use words from previous command lines in the command line you are typing. This simplifies spelling corrections and the repetition of complicated commands or arguments.
Command lines are saved in the history list, the size of which is controlled by the <command>history</command> variable. The <command>history</command> shell variable may be set to the maximum number of
command lines that will be saved in the history file; i.e.:<informalexample><programlisting>set history = 200</programlisting>
</informalexample>will allow the history list to keep track of the most recent 200 command lines. If not set, the C shell saves only the most recent command.</para>
<para>A history substitution begins with a <literal>!</literal> (although you can change this with the <literal>histchars</literal> variable) and may occur anywhere on the command line; history substitutions
do not nest. The <literal>!</literal> can be escaped with <literal>&bsol;</literal> to suppress its special meaning.</para>
<para>Input lines containing history substitutions are echoed on the terminal after being expanded, but before any other substitutions take place or the command gets executed.</para>
</refsect3>
<refsect3><title>Event Designators:</title>
<para>An event designator is a reference to a command line entry in the history list.</para>
<variablelist termlength="wide"><varlistentry><term remap="45"><literal>!</literal></term><listitem><para>Start a history substitution, except when followed by a space character, tab, newline, <literal>
=</literal> or <literal>(</literal>.</para>
</listitem></varlistentry>
<varlistentry><term><literal>!!</literal></term><listitem><para>Refer to the previous command. By itself, this substitution repeats the previous command.</para>
</listitem></varlistentry>
<varlistentry><term><literal>!</literal><replaceable>n</replaceable></term><listitem><para>Refer to command line <replaceable>n</replaceable>.</para>
</listitem></varlistentry>
<varlistentry><term><literal>!</literal><option>n</option></term><listitem><para>Refer to the current command line minus <replaceable>n</replaceable>.</para>
</listitem></varlistentry>
<varlistentry><term><literal>!</literal><replaceable>str</replaceable></term><listitem><para>Refer to the most recent command starting with <replaceable>str</replaceable>.</para>
</listitem></varlistentry>
<varlistentry><term><literal>!?</literal><replaceable>str</replaceable><literal>?</literal></term><listitem><para>Refer to the most recent command containing <replaceable>str</replaceable>.</para>
</listitem></varlistentry>
<varlistentry><term><literal>!?</literal><replaceable>str</replaceable><literal>? </literal><replaceable>additional</replaceable></term><listitem><para>Refer to the most recent command containing <replaceable>
str</replaceable> and append <replaceable>additional</replaceable> to that referenced command.</para>
</listitem></varlistentry>
<varlistentry><term><literal>!{</literal><command>command</command><literal>} </literal><replaceable>additional</replaceable></term><listitem><para>Refer to the most recent command beginning with <command>
command</command> and append <replaceable>additional</replaceable> to that referenced command.</para>
</listitem></varlistentry>
<varlistentry><term><literal>&caret;</literal><replaceable>previous_word</replaceable><literal>&caret;</literal><replaceable>replacement</replaceable><literal>&caret;</literal></term><listitem><para>Repeat
the previous command line replacing the string <replaceable>previous_word</replaceable> with the string <replaceable>replacement</replaceable>. This is equivalent to the history substitution:<informalexample>
<programlisting><literal>!:s/</literal><replaceable>previous_word</replaceable><literal>/</literal><replaceable>replacement</replaceable><literal>/</literal>.</programlisting>
</informalexample>To re-execute a specific previous command AND make such a substitution, say, re-executing command #6,<informalexample><programlisting><literal>!:6s/</literal><replaceable>previous_word
</replaceable><literal>/</literal><replaceable>replacement</replaceable><literal>/</literal>.</programlisting>
</informalexample></para>
</listitem></varlistentry>
</variablelist>
</refsect3>
<refsect3><title>Word Designators:</title>
<para>A `<literal>:</literal>' (colon) separates the event specification from the word designator. 2It can be omitted if the word designator begins with a <literal>&caret;</literal>, <literal>$</literal>, <literal>
*</literal>, <literal>&minus;</literal> or <literal>%</literal>. If the word is to be selected from the previous command, the second <literal>!</literal> character can be omitted from the event specification.
For instance, <literal>!!:1</literal> and <literal>!:1</literal> both refer to the first word of the previous command, while <literal>!!$</literal> and <literal>!$</literal> both refer to the last word
in the previous command. Word designators include:<variablelist termlength="narrow"><varlistentry><term remap="9"><literal>#</literal></term><listitem><para>The entire command line typed so far.</para>
</listitem></varlistentry>
<varlistentry><term><literal>0</literal></term><listitem><para>The first input word (command).</para>
</listitem></varlistentry>
<varlistentry><term><replaceable>n</replaceable> </term><listitem><para>The <replaceable>n</replaceable>'th argument.</para>
</listitem></varlistentry>
<varlistentry><term><literal>&caret;</literal></term><listitem><para>The first argument, that is, <literal>1</literal>.</para>
</listitem></varlistentry>
<varlistentry><term><literal>$</literal></term><listitem><para>The last argument.</para>
</listitem></varlistentry>
<varlistentry><term><literal>%</literal></term><listitem><para>The word matched by (the most recent) <literal>?</literal><replaceable>s</replaceable> search.</para>
</listitem></varlistentry>
<varlistentry><term><replaceable>x</replaceable><literal>&minus;</literal><replaceable>y</replaceable></term><listitem><para>A range of words; <literal>&minus;</literal><replaceable>y</replaceable> abbreviates <literal>
0&minus;</literal><replaceable>y</replaceable>.</para>
</listitem></varlistentry>
<varlistentry><term><literal>*</literal></term><listitem><para>All the arguments, or a null value if there is just one word in the event.</para>
</listitem></varlistentry>
<varlistentry><term><replaceable>x</replaceable><literal>*</literal></term><listitem><para>Abbreviates <replaceable>x</replaceable><literal>&minus;$</literal><replaceable>.</replaceable></para>
</listitem></varlistentry>
<varlistentry><term><replaceable>x</replaceable><literal>&minus;</literal></term><listitem><para>Like <replaceable>x*</replaceable> but omitting word <literal>$</literal>.</para>
</listitem></varlistentry>
</variablelist></para>
</refsect3>
<refsect3><title>Modifiers:</title>
<para>After the optional word designator, you can add a sequence of one or more of the following modifiers, each preceded by a <literal>:</literal>.</para>
<variablelist termlength="wholeline"><varlistentry><term remap="234"><literal>h</literal></term><listitem><para>Remove a trailing pathname component, leaving the head.</para>
</listitem></varlistentry>
<varlistentry><term><literal>r</literal></term><listitem><para>Remove a trailing suffix of the form `<literal>.</literal><replaceable>xxx</replaceable>', leaving the basename.</para>
</listitem></varlistentry>
<varlistentry><term><literal>e</literal></term><listitem><para>Remove all but the suffix, leaving the extension.</para>
</listitem></varlistentry>
<varlistentry><term><literal>s/</literal><replaceable>oldchars</replaceable><literal>/</literal><replaceable>replacements</replaceable><literal>/</literal> Substitute </term><listitem><para><replaceable>
replacements</replaceable> for <replaceable>oldchars</replaceable>. <replaceable>oldchars</replaceable> is a string that may contain embedded blank spaces, whereas <replaceable>previous_word</replaceable>
in the event designator <informalexample><programlisting><literal>&caret;</literal><replaceable>oldchars</replaceable><literal>&caret;</literal><replaceable>replacements</replaceable><literal>&caret;</literal></programlisting>
</informalexample> may not.</para>
</listitem></varlistentry>
<varlistentry><term><literal>t</literal></term><listitem><para>Remove all leading pathname components, leaving the tail.</para>
</listitem></varlistentry>
<varlistentry><term><literal>&amp;</literal></term><listitem><para>Repeat the previous substitution.</para>
</listitem></varlistentry>
<varlistentry><term><literal>g</literal></term><listitem><para>Apply the change to the first occurrence of a match in each word, by prefixing the above (for example, <literal>g&amp;</literal>).</para>
</listitem></varlistentry>
<varlistentry><term><literal>p</literal></term><listitem><para>Print the new command but do not execute it.</para>
</listitem></varlistentry>
<varlistentry><term><literal>q</literal></term><listitem><para>Quote the substituted words, escaping further substitutions.</para>
</listitem></varlistentry>
<varlistentry><term><literal>x</literal></term><listitem><para>Like <literal>q</literal>, but break into words at each space character, tab or newline.</para>
</listitem></varlistentry>
</variablelist>
<para>Unless preceded by a <literal>g</literal>, the modification is applied only to the first string that matches <replaceable>oldchars</replaceable>; an error results if no string matches.</para>
<para>The left-hand side of substitutions are not regular expressions, but character strings. Any character can be used as the delimiter in place of <literal>/</literal>. A backslash quotes the delimiter
character. The character <literal>&amp;</literal>, in the right hand side, is replaced by the text from the left-hand-side. The <literal>&amp;</literal> can be quoted with a backslash. A null <replaceable>
oldchars</replaceable> uses the previous string either from a <replaceable>oldchars</replaceable> or from a contextual scan string <replaceable>s</replaceable> from <literal>!?</literal><replaceable>s</replaceable>.
You can omit the rightmost delimiter if a newline immediately follows <replaceable>replacements</replaceable>; the rightmost <literal>?</literal> in a context scan can similarly be omitted.</para>
<para>Without an event specification, a history reference refers either to the previous command, or to a previous history reference on the command line (if any).</para>
</refsect3>
</refsect2>
<refsect2><title>ksh</title>
<para>Using <command>fc</command>, in the form of <informalexample>
<para><literal>fc <option>e</option> &minus;</literal> [ <replaceable>old</replaceable><literal>=</literal><replaceable>new</replaceable> ] [ <replaceable>command</replaceable> ], </para>
</informalexample>the <replaceable>command</replaceable> is re-executed after the substitution <replaceable>old</replaceable><literal>=</literal><replaceable>new</replaceable> is performed. If there is
not a <replaceable>command</replaceable> argument, the most recent command typed at this terminal is executed.</para>
<para>Using <command>fc</command> in the form of<informalexample>
<para><command>fc</command> [ <option>e</option> <replaceable>ename</replaceable> ] [ <option>nlr</option> ] [ <replaceable>first</replaceable> [ <replaceable>last</replaceable> ] ],</para>
</informalexample>a range of commands from <replaceable>first</replaceable> to <replaceable>last</replaceable> is selected from the last <literal remap="small and bold">HISTSIZE</literal> commands that
were typed at the terminal.  The arguments <replaceable>first</replaceable> and <replaceable>last</replaceable> may be specified as a number or as a string. A string is used to locate the most recent command
starting with the given string.  A negative number is used as an offset to the current command number.  If the <option>l</option> flag is selected, the commands are listed on standard output. Otherwise,
the editor program <option>e</option> <replaceable>name</replaceable> is invoked on a file containing these keyboard commands.  If <replaceable>ename</replaceable> is not supplied, then the value of the
variable <literal remap="small and bold">FCEDIT</literal> (default <literal>/bin/ed</literal>) is used as the editor.  When editing is complete, the edited command(s) is executed.  If <command>last</command>
is not specified then it will be set to <replaceable>first</replaceable>. If <replaceable>first</replaceable> is not specified the default is the previous command for editing and &minus;16 for listing.
 The flag <option>r</option> reverses the order of the commands and the flag <option>n</option> suppresses command numbers when listing. (See <link linkend="ksh-1"><citerefentry><refentrytitle>ksh</refentrytitle>
<manvolnum>1</manvolnum></citerefentry></link> for more about command line editing.)</para>
<variablelist termlength="narrow"><varlistentry><term remap="9"><envar>HISTFILE</envar> </term><listitem><para>If this variable is set when the shell is invoked, then the value is the pathname of the file
that will be used to store the command history.</para>
</listitem></varlistentry>
<varlistentry><term><envar>HISTSIZE</envar> </term><listitem><para>If this variable is set when the shell is invoked, then the number of previously entered commands that are accessible by this shell will
be greater than or equal to this number.  The default is <literal>128</literal>.</para>
</listitem></varlistentry>
</variablelist>
<refsect3><title>Command Re-entry:</title>
<para>The text of the last <envar>HISTSIZE</envar> (default 128) commands entered from a terminal device is saved in a <command>history</command> file.  The file <filename>$HOME/.sh_history</filename> is
used if the <envar>HISTFILE</envar> variable is not set or if the file it names is not writable. A shell can access the commands of all <replaceable>interactive</replaceable> shells which use the same named <envar>
HISTFILE</envar>.  The special command <command>fc</command> is used to list or edit a portion of this file. The portion of the file to be edited or listed can be selected by number or by giving the first
character or characters of the command. A single command or range of commands can be specified. If you do not specify an editor program as an argument to <command>fc</command> then the value of the variable <envar>
FCEDIT</envar> is used.  If <envar>FCEDIT</envar> is not defined then <command>/bin/ed</command> is used. The edited command(s) is printed and re-executed upon leaving the editor.  The editor name <literal>
&minus;</literal> is used to skip the editing phase and to re-execute the command. In this case a substitution parameter of the form <replaceable>old</replaceable><literal>=</literal><replaceable>new</replaceable>
can be used to modify the command before execution.  For example, if <literal>r</literal> is aliased to <literal> &acute;fc</literal> <option>e</option> <literal>&minus; &acute;</literal> then typing <literal>
`r</literal> <literal>bad=good</literal> <literal>c'</literal> will re-execute the most recent command which starts with the letter <literal>c</literal>, replacing the first occurrence of the string <literal>
bad</literal> with the string <literal>good</literal>.</para>
<para>Using the <command>fc</command> built-in command within a compound command will cause the whole command to disappear from the history file.</para>
</refsect3>
</refsect2>
</refsect1>
<refsect1><title>&opts-tt;</title>
<para>The following options are supported:<variablelist termlength="narrow"><varlistentry><term remap="9"><literal><option>e</option>  </literal><replaceable>editor</replaceable></term><listitem><para>
Use the editor named by <replaceable>editor</replaceable> to edit the commands. The <replaceable>editor</replaceable> string is a utility name, subject to search via the <envar>PATH</envar> variable. The
value in the <envar>FCEDIT</envar> variable is used as a default when <option>e</option> is not specified. If <envar>FCEDIT</envar> is null or unset, <command>ed</command> will be used as the editor.</para>
</listitem></varlistentry>
<varlistentry><term><option>l</option> </term><listitem><para>(The letter ell.) List the commands rather than invoking an editor on them. The commands will be written in the sequence indicated by the <replaceable>
first</replaceable> and <replaceable>last</replaceable> operands, as affected by <option>r</option>, with each command preceded by the command number.</para>
</listitem></varlistentry>
<varlistentry><term><option>n</option> </term><listitem><para>Suppress command numbers when listing with <option>l</option>.</para>
</listitem></varlistentry>
<varlistentry><term><option>r</option> </term><listitem><para>Reverse the order of the commands listed (with <option>l</option> <literal>)</literal> or edited (with neither <option>l</option> nor <option>
s</option>).</para>
</listitem></varlistentry>
<varlistentry><term><option>s</option> </term><listitem><para>Re-execute the command without invoking an editor.</para>
</listitem></varlistentry>
</variablelist></para>
</refsect1>
<refsect1><title>&oper-tt;</title>
<para>The following operands are supported:</para>
<variablelist termlength="xtranarrow"><varlistentry><term><replaceable>first</replaceable></term><term remap="12"><replaceable> last</replaceable></term><listitem><para>Select the commands to list or edit.
The number of previous commands that can be accessed is determined by the value of the <envar>HISTSIZE</envar> variable. The value of <replaceable>first</replaceable> or <replaceable>last</replaceable>
or both will be one of the following:</para>
<variablelist termlength="narrow"><varlistentry><term remap="12">[<literal>+</literal>]<replaceable>number</replaceable></term><listitem><para>A positive number representing a command number; command numbers
can be displayed with the <option>l</option> option.</para>
</listitem></varlistentry>
<varlistentry><term><literal>&minus;</literal><replaceable>number</replaceable></term><listitem><para>A negative decimal number representing the command that was executed <replaceable>number</replaceable>
of commands previously. For example, &minus;1 is the immediately previous command.</para>
</listitem></varlistentry>
<varlistentry><term><replaceable>string</replaceable></term><listitem><para>A string indicating the most recently entered command that begins with that string. If the <replaceable>old=new</replaceable>
operand is not also specified with <option>s</option>, the string form of the <replaceable>first</replaceable> operand cannot contain an embedded equal sign.</para>
<para>When the synopsis form with <option>s</option> is used:<itemizedlist mark="bullet">
<listitem><para>If <replaceable>first</replaceable> is omitted, the previous command will be used.</para>
</listitem></itemizedlist>For the synopsis forms without <option>s</option> <literal>:</literal><itemizedlist mark="bullet">
<listitem><para>If <replaceable>last</replaceable> is omitted, <replaceable>last</replaceable> defaults to the previous command when <option>l</option> is specified; otherwise, it defaults to <replaceable>
first</replaceable>.</para>
</listitem><listitem><para>If <replaceable>first</replaceable> and <replaceable>last</replaceable> are both omitted, the previous 16 commands will be listed or the previous single command will be edited
(based on the <option>l</option> option).</para>
</listitem><listitem><para>If <replaceable>first</replaceable> and <replaceable>last</replaceable> are both present, all of the commands from <replaceable>first</replaceable> to <replaceable>last</replaceable>
will be edited (without <option>l</option> <literal>)</literal> or listed (with <option>l</option>). Editing multiple commands will be accomplished by presenting to the editor all of the commands at one
time, each command starting on a new line. If <replaceable>first</replaceable> represents a newer command than <replaceable>last</replaceable>, the commands will be listed or edited in reverse sequence,
equivalent to using <option>r</option> <literal>.</literal> For example, the following commands on the first line are equivalent to the corresponding commands on the second:<informalexample><programlisting>
fc <option>r</option> 10 20     fc    30 40 
fc   20 10      fc <option>r</option> 40 30</programlisting>
</informalexample></para>
</listitem><listitem><para>When a range of commands is used, it will not be an error to specify <replaceable>first</replaceable> or <replaceable>last</replaceable> values that are not in the history list; <command>
fc</command> will substitute the value representing the oldest or newest command in the list, as appropriate. For example, if there are only ten commands in the history list, numbered 1 to 10:<informalexample>
<programlisting>fc -l 
fc 1 99</programlisting>
</informalexample>will list and edit, respectively, all ten commands.</para>
</listitem></itemizedlist></para>
</listitem></varlistentry>
<varlistentry><term><replaceable>old=new</replaceable> </term><listitem><para>Replace the first occurrence of string <replaceable>old</replaceable> in the commands to be reexecuted by the string <replaceable>
new</replaceable>.</para>
</listitem></varlistentry>
</variablelist>
</listitem></varlistentry>
</variablelist>
</refsect1>
<refsect1><title>OUTPUT</title>
<para>When the <option>l</option> option is used to list commands, the format of each command in the list is as follows:<informalexample><programlisting><literal>"%d&bsol;t%s&bsol;n", &lt;</literal><replaceable>
line number</replaceable><literal>>, &lt;</literal><replaceable>command</replaceable><literal>></literal></programlisting>
</informalexample></para>
<para>If both the <option>l</option> and <option>n</option> options are specified, the format of each command is:<informalexample><programlisting><literal>"&bsol;t%s&bsol;n", &lt;</literal><replaceable>
command</replaceable><literal>></literal></programlisting>
</informalexample></para>
<para>If the <replaceable>command</replaceable><replaceable>command</replaceable> consists of more than one line, the lines after the first are displayed as:<informalexample><programlisting><literal>"&bsol;t%s&bsol;n", &lt;
</literal><replaceable>continued-command</replaceable><literal>></literal></programlisting>
</informalexample></para>
</refsect1>
<refsect1><title>&exam-tt;</title>
<example role="example"><title>Using <command>history</command> and <command>fc</command></title>
<para><programlisting>

             csh                                     ksh

% history                               $ fc -l
  1   cd /etc                             1   cd /etc
  2   vi passwd                           2   vi passwd
  3   date                                3   date
  4   cd                                  4   cd
  5   du .                                5   du .
  6   ls -t                               6   ls -t
  7   history                             7   fc -l

% !d                                    $ fc -e - d
  du .                                    du .
  262   ./SCCS                            262   ./SCCS
  336   .                                 336   .

% !da                                   $ fc -e - da
  Thu Jul 21 17:29:56 PDT 1994            Thu Jul 21 17:29:56 PDT 1994

%                                       $ alias &bsol;!='fc -e -'

% !!                                    $ !
  date                                    alias ='fc -e -'
  Thu Jul 21 17:29:56 PDT 1994

</programlisting></para>
</example>
</refsect1>
<refsect1><title>&envr-tt;</title>
<para>See <olink targetdocent="REFMAN5" localinfo="environ-5"><citerefentry><refentrytitle>environ</refentrytitle><manvolnum>5</manvolnum></citerefentry></olink> for descriptions of the following environment
variables that affect the execution of <command>fc</command>: <envar>LC_CTYPE</envar>, <envar>LC_MESSAGES</envar>, and <envar>NLSPATH</envar>.</para>
<variablelist termlength="narrow"><varlistentry><term remap="9"><envar>FCEDIT</envar> </term><listitem><para>This variable, when expanded by the shell, determines the default value for the <literal>e</literal> <replaceable>
editor</replaceable> option's <replaceable>editor</replaceable> option-argument. If <envar>FCEDIT</envar> is null or unset, <command>ed</command> will be used as the editor.</para>
</listitem></varlistentry>
<varlistentry><term><envar>HISTFILE</envar> </term><listitem><para>Determine a pathname naming a command history file. If the <envar>HISTFILE</envar> variable is not set, the shell may attempt to access
or create a file <literal>.sh_history</literal> in the user's home directory. If the shell cannot obtain both read and write access to, or create, the history file, it will use an unspecified mechanism
that allows the history to operate properly. (References to history ``file'' in this section are understood to mean this unspecified mechanism in such cases.) <command>fc</command> may choose to access
this variable only when initializing the history file; this initialization will occur when <command>fc</command> or <command>sh</command> first attempt to retrieve entries from, or add entries to, the file,
as the result of commands issued by the user, the file named by the <envar>ENV</envar> variable, or a system startup file such as <filename>/etc/profile</filename>. (The initialization process for the history
file can be dependent on the system startup files, in that they may contain commands that will effectively preempt the user's settings of <envar>HISTFILE</envar> and <envar>HISTSIZE</envar>. For example,
function definition commands are recorded in the history file, unless the <command>set</command> <option>o</option> <literal>nolog</literal> option is set. If the system administrator includes function
definitions in some system startup file called before the <envar>ENV</envar> file, the history file will be initialized before the user gets a chance to influence its characteristics.) The variable <envar>
HISTFILE</envar> is accessed initially when the shell is invoked. Any changes to <envar>HISTFILE</envar> will not take effect until another shell is invoked.</para>
</listitem></varlistentry>
<varlistentry><term><envar>HISTSIZE</envar> </term><listitem><para>Determine a decimal number representing the limit to the number of previous commands that are accessible. If this variable is unset, an
unspecified default greater than or equal to 128 will be used. The variable <envar>HISTSIZE</envar> is accessed initially when the shell is invoked. Any changes to <envar>HISTSIZE</envar> will not take
effect until another shell is invoked.</para>
</listitem></varlistentry>
</variablelist>
</refsect1>
<refsect1><title>&exit-tt;</title>
<para>The following exit values are returned:</para>
<variablelist termlength="xtranarrow"><varlistentry><term remap="3"><returnvalue>0</returnvalue> </term><listitem><para>Successful completion of the listing.</para>
</listitem></varlistentry>
<varlistentry><term><returnvalue>>0</returnvalue> </term><listitem><para>An error occurred.</para>
</listitem></varlistentry>
</variablelist>
<para>Otherwise, the exit status will be that of the commands executed by <command>fc</command>.</para>
</refsect1>
<refsect1><title>&attr-tt;</title>
<para>See <olink targetdocent="REFMAN5" localinfo="attributes-5"><citerefentry><refentrytitle>attributes</refentrytitle><manvolnum>5</manvolnum></citerefentry></olink> for descriptions of the following
attributes:</para>
<informaltable frame="all" orient="port"><tgroup cols="2" colsep="1" rowsep="1"><colspec colname="col1" colwidth="198*" align="left"><colspec colname="col2" colwidth="198*" align="left"><thead><row><entry
align="center" valign="top">ATTRIBUTE TYPE</entry><entry align="center" valign="top">ATTRIBUTE VALUE</entry></row></thead><tbody><row><entry align="left" valign="top">Availability</entry><entry align="left"
valign="top">SUNWcsu</entry></row></tbody></tgroup></informaltable>
</refsect1>
<refsect1><title>&also-tt;</title>
<para><link linkend="csh-1"><citerefentry><refentrytitle>csh</refentrytitle><manvolnum>1</manvolnum></citerefentry></link>, <link linkend="ed-1"><citerefentry><refentrytitle>ed</refentrytitle><manvolnum>
1</manvolnum></citerefentry></link>, <link linkend="ksh-1"><citerefentry><refentrytitle>ksh</refentrytitle><manvolnum>1</manvolnum></citerefentry></link>, <link linkend="set-1"><citerefentry><refentrytitle>
set</refentrytitle><manvolnum>1</manvolnum></citerefentry></link>, <olink targetdocent="REFMAN1" localinfo="set-1f"><citerefentry><refentrytitle>set</refentrytitle><manvolnum>1F</manvolnum></citerefentry></olink>, <link
linkend="sh-1"><citerefentry><refentrytitle>sh</refentrytitle><manvolnum>1</manvolnum></citerefentry></link>, <link linkend="source-1"><citerefentry><refentrytitle>source</refentrytitle><manvolnum>1</manvolnum>
</citerefentry></link>, <olink targetdocent="REFMAN5" localinfo="attributes-5"><citerefentry><refentrytitle>attributes</refentrytitle><manvolnum>5</manvolnum></citerefentry></olink>, <olink targetdocent="REFMAN5"
localinfo="environ-5"><citerefentry><refentrytitle>environ</refentrytitle><manvolnum>5</manvolnum></citerefentry></olink></para>
</refsect1>
<!--+ 03/20/98 18:35:59     | tagMorph:  $Id: tagMorph-engine 1.54 1998/01-->
<!--/19 05:44:48 $     | tagMorph library:  $Id: libtagMorph.a 1.50 1998/0-->
<!--1/19 22:02:51 $     | sunman-to-solbook 1.17     +-->
</refentry>
