DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

fc(1)


fc -- process command history list

Synopsis

/u95/u95/bin/fc [-r][-e editor] [first [last]] /usr/bin/fc [-l][-nr] [first [last]] /usr/bin/fc [-s] [old=new[first]]

Description

This shell script executes the builtin command of the same name as implemented by the /u95/bin/sh( ) shell. See ksh(1) for more information on this shell.

The fc command lists or edits and reexecutes, commands previously entered to an interactive ksh(1).

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 commands are edited (when the -l option is not specified), the resulting lines will be entered at the end of the history list and then reexecuted by the shell. The fc 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 fc will affect both the fc command itself as well as the command that results. For example:

fc -s -- -1 2>/dev/null

reinvokes the previous command, suppressing standard error for both fc and the previous command.

Flags

The following options are supported:

-e editor
Use the editor named by editor to edit the commands. The editor string is a utility name, subject to search via the PATH variable. The value in the FCEDIT variable is used as a default when -e is not specified. If FCEDIT is null or unset, ed(1) will be used as the editor.

-l
List the commands rather than invoking an editor on them. The commands will be written in the sequence indicated by the first and last operands, as affected by -r, with each command preceded by the command number.

-n
Suppress command numbers when listing with -l.

-r
Reverse the order of the commands listed (with -l) or edited (with neither -l nor -s).

-s
Reexecute the command without invoking an editor.

Operands

The following operands are supported:

first

last
Select the commands to list or edit. The number of previous commands that can be accessed is determined by the value of the HISTSIZE variable. The value of first or last or both will be one of the following:

[+]number
A positive number representing a command number; command numbers can be displayed with the -l option.

-number
A negative decimal number representing the command that was executed number of commands previously. For example, -1 is the immediately previous command.

string
A string indicating the most recently entered command that begins with that string. If the old=new operand is not also specified with -s, the string form of the first operand cannot contain an embedded equal sign.

When -s is used and first is omitted, the previous command is used.

When -s is not specified:


old=new
Replace the first occurrence of string old in the commands to be reexecuted by the string new.

Environment variables

The following environment variables affect the execution of fc:

FCEDIT
This variable, when expanded by the shell, determines the default value for the -e option's editor operand. If FCEDIT is null or unset, ed(1) will be used as the editor.

HISTFILE
Determine a pathname naming a command history file. If the HISTFILE variable is not set, the shell will attempt to access or create a file .sh_history in the user's home directory. Users on windowing systems may want to have separate history files for each window by setting HISTFILE as follows:

HISTFILE=$HOME/.sh_hist$$


HISTSIZE
A decimal number representing the limit to the number of previous commands that are accessible. The default is 128.

LANG
Provide a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.

LC_ALL
If set to a non-empty string value, override the values of all the other internationalization variables.

LC_CTYPE
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files).

LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.

Output

When the -l option is used to list commands, the format of each command in the list is as follows:

line_number<Tab>command_line

If both the -l and -n options are specified, the format of each command is:

<Tab>command_line

If the command_line contains more characters than can be shown on one display line, the lines after the first are displayed as:

<Tab>command_line2
...
<Tab>command_lineN

Exit codes

When listing or editing commands, an exit value of 0 indicates successful completion of the operation; any other exit code indicates an error. Otherwise, the exit status will be that of the commands executed by fc.

Usage

Since editors sometimes use file descriptors as integral parts of their editing, redirecting their file descriptors as part of the fc command can produce unexpected results. For example, if vi(1) is the FCEDIT editor, the command:

fc -s | more

will not work correctly.

References

ksh(1)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 02 June 2005