Using the Korn Shell

Turn on extended command history

To start recording the date and time that each command is executed, set the EXTENDED_HISTORY environment variable to ON:

export EXTENDED_HISTORY=ON

The CUT (Coordinated Universal Time) timestamp will be appended to each line of the ~/.sh_history file.

Display command history

The command history can be displayed with various history or fc (fix command) commands:

history
fc -l
history n
fc -l n

fc -t
history -t
fc -t n
history -t n

n specifies which command the listing is to start with. If it is negative, then the listing starts with the nth previous commmand; if it is non-negative, the listing starts with the specified command number. If -t is specified, the output will include the timestamps.

Repeat a previous command

r

without any parameters repeats the preceding command.

r searchtext

repeats the last command starting with the given search text.

r -n

repeats the nth previous command.

r n

repeats the specified command. The number of a command can be determined by displaying the command history or by setting the prompt to include the command number.

Last updated Tuesday October 3, 2006


Printer-friendly PDF* format:

Using the Korn Shell

This Section

You are currently viewing this page in XHTML 1 Style Sheet* format (* see Clicklets for more infomation). This document is also available in XHTML 1*XML*HTML 4*HTML 5 Style Sheet*HTML 5 XML*HTML 5 non-XML* XHTML 2* XHTML Mobile* WML Mobile* and printer-friendly PDF* formats. This is accomplished with Single Source Publishing, a content management system that uses templates in XSLT style sheets provided by XML Styles .com to transform the source content for various content delivery channels. There is also RDF* metadata that describes the content of this document.