<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/styles/XMLStylesDoc_xhtml11_en.xsl"?><!DOCTYPE document SYSTEM "/schemas/XMLStyles10.dtd">
<document xmlns="http://XMLStyles.com/namespaces/styles" xmlns:xst="http://XMLStyles.com/namespaces/styles" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:date="http://exslt.org/dates-and-times">
   <noxml>
      <p xmlns="http://www.w3.org/1999/xhtml"/>
      <!-- You are viewing the source.  The following message should be ignored if you did "View Source" in your browser. -->
      <p xmlns="http://www.w3.org/1999/xhtml">
ATTENTION: XML WEB PAGES NOT SUPPORTED
   If you see this message, your current browser does not support the
   1999 XSLT 1.0 (or later) standard for XML web pages such as this one.
   Please upgrade your browser to a newer version
   that supports 1999 or later standards such as:
      Mozilla Firefox version 1.0.2 or later (GetFirefox -&gt; http://www.GetFirefox.com/)
      Netscape version 8 or later
      Safari version 1.3 or later
      Opera version 9 or later
      Microsoft Internet Explorer (MSIE) version 5 or later
   For further assistance, contact the software vendor for your browser.
   To go to the X<!-- extended HTML -->HTML version of this page click the following link:
<a href="index.html">index.html</a>
      </p>
      <p xmlns="http://www.w3.org/1999/xhtml">&#160;</p>
   </noxml>
   <path>/computers/os/unix/shell/korn/</path>
   <site>How To Guides</site>
   <logo xlink:type="simple" xlink:href="/images/howtohome.jpg" media="screen" width="240" height="34">How To Guides</logo>
   <logo xlink:type="simple" xlink:href="/images/howtoguides.jpg" media="print" width="240" height="34">How To Guides</logo>
   <logo xlink:type="simple" xlink:href="/images/howtoguidesmobile.jpg" media="handheld" width="150" height="17">How To Guides</logo>
   <navigation where="sections">
      <label>How To Guides</label>
      <link xlink:type="simple" xlink:href="/business/index.xml">Business</link>
      <link xlink:type="simple" xlink:href="/computers/index.xml">Computers</link>
      <link xlink:type="simple" xlink:href="/computers/databases/index.xml">Databases</link>
      <link xlink:type="simple" xlink:href="/internet/index.xml">Internet</link>
      <link xlink:type="simple" xlink:href="/mobile/index.xml">Mobile</link>
      <link xlink:type="simple" xlink:href="/money/index.xml">Money</link>
      <link xlink:type="simple" xlink:href="/movies/index.xml">Movies</link>
      <link xlink:type="simple" xlink:href="/computers/os/index.xml">Operating Systems</link>
   </navigation>
   <navigation where="up">
      <link xlink:type="simple" xlink:href="../../../../">Computers</link>
      <link xlink:type="simple" xlink:href="../../../">Operating Systems</link>
      <link xlink:type="simple" xlink:href="../../">UNIX</link>
      <link xlink:type="simple" xlink:href="../">Shell</link>
   </navigation>
   <navigation where="subsections">
      <link xlink:type="simple" xlink:href="index.xml">Korn Shell</link>
      <link xlink:type="simple" xlink:href="../csh/">C Shell</link>
      <link xlink:type="simple" xlink:href="/computers/os/unix/commands/">Commands</link>
      <link xlink:type="simple" xlink:href="/computers/os/unix/tcpip/">TCP/IP</link>
      <link xlink:type="simple" xlink:href="/computers/os/unix/xwindows/">X Windows</link>
      <link xlink:type="simple" xlink:href="/computers/os/unix/admin/">Admin.</link>
      <link xlink:type="simple" xlink:href="/computers/os/unix/admin/commands/">Admin. Commands</link>
      <link xlink:type="simple" xlink:href="/computers/os/unix/admin/security/">Security</link>
   </navigation>
   <section id="body" type="body">
      <pages name="index">
         <title>Using the Korn Shell</title>
         <label>Korn Shell</label>
         <navigation where="pages">
            <label>Korn Shell</label>
            <link xlink:type="simple" xlink:href="index.xml">Summary</link>
            <link xlink:type="simple" xlink:href="profile.xml">.profile</link>
            <link xlink:type="simple" xlink:href="prompt.xml">Prompt</link>
            <link xlink:type="simple" xlink:href="cmdedit.xml">Command Editing</link>
            <link xlink:type="simple" xlink:href="history.xml">History</link>
            <link xlink:type="simple" xlink:href="setpath.xml">Set PATH</link>
            <link xlink:type="simple" xlink:href="special.xml">Special Built-ins</link>
            <link xlink:type="simple" xlink:href="builtin.xml">Regular Built-ins</link>
         </navigation>
         <h1>Using the Korn Shell</h1>
         <page id="N1028D" name="history">
            <title>Command History</title>
            <label>History</label>
            <description>Display, fix and repeat previously entered commands.</description>
            <navigation where="up">
               <link xlink:type="simple" xlink:href="index.xml">Korn</link>
            </navigation>
            <h1>Turn on extended command history</h1>
            <p>To start recording the date and time that each command is executed, set
               the <code>EXTENDED_HISTORY</code> environment variable to <code>ON</code>:
            </p>
            <blockcode>
               <l>export EXTENDED_HISTORY=ON</l>
            </blockcode>
            <p>The CUT (Coordinated Universal Time) timestamp will be appended
               to each line of the <code>~/.sh_history</code> file.
            </p>
            <h1>Display command history</h1>
            <p>The command history can be displayed with various <code>history</code>
               or <code>fc</code> (<span class="output">fix command</span>) commands:
            </p>
            <blockcode>
               <l>history</l>
               <l>fc -l</l>
               <l>history <i>n</i>​</l>
               <l>fc -l <i>n</i>​</l>
               <br/>
               <l>fc -t</l>
               <l>history -t</l>
               <l>fc -t <i>n</i>​</l>
               <l>history -t <i>n</i>​</l>
            </blockcode>
            <p>
               <code>n</code> specifies which command the listing is to start with.
               If it is negative, then the listing starts with the <i>n</i>th previous commmand;
               if it is non-negative, the listing starts with the specified command number.
               If <code>-t</code> is specified, the output will include the timestamps.
            </p>
            <h1>Repeat a previous command</h1>
            <blockcode>
               <l>r</l>
            </blockcode>
            <p>without any parameters repeats the preceding command.
            </p>
            <blockcode>
               <l>r <i>searchtext</i>​</l>
            </blockcode>
            <p>repeats the last command starting with the given search text.
            </p>
            <blockcode>
               <l>r -<i>n</i>​</l>
            </blockcode>
            <p>repeats the <i>n</i>th previous command.
            </p>
            <blockcode>
               <l>r <i>n</i>​</l>
            </blockcode>
            <p>repeats the specified command.  The number of a command can be determined by displaying the command history
               or by <link xlink:type="simple" xlink:href="prompt.xml">setting the prompt</link> to include the command number.
            </p>
            <updated local="2006-10-03">Tuesday October 3, 2006</updated>
         </page>
      </pages>
   </section>
   <copyright>Copyright © 2006 How To Guides .com. Alteration of content, including addition of any function such as hypertext links or pop-up advertising, or interference with the hypertext links or other functions of this site is expressly prohibited.</copyright>
   <disclaimer>All information, links, forms, applications and other items on this site or obtained from it are provided <b>AS IS</b>, WITHOUT WARRANTY OF ANY KIND EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.</disclaimer>
   <ids urchin="UA-779578-2"/>
</document>

