HP NonStop G-Series User Manual

Page 42

Advertising
background image

To display the command history buffer and edit its contents, use the built-in command fc (fix
command). The fc command has two formats. The first format is as follows:

fc [-e editor] [-nlr] [first] [last]

This command format allows you to display and edit any number of command lines in your buffer.

The -e editor entry specifies the editor (usually vi) you wish to use in editing the command
line. If you do not specify -e editor, the fc command displays the lines but does not allow
you to edit them.

The -n flag specifies that you wish to list the command lines in the buffer without line numbers.
The -l flag specifies that you wish to list the command lines in the buffer with line numbers.
If you do not specify a line number or a range of line numbers, the last 16 lines you entered
are listed.

The -r flag specifies that you wish to list the commands in the buffer in reverse order.

The first and last entries specify a range of command lines in the buffer. You can specify
them either with numbers or with strings.

The second format of the fc command allows you to specify a default editor for the -e flag in
your .profile script.

For example, if you want to make vi your default editor, enter the following variable definition in
your .profile file:

FCEDIT=vi

In the following command, vi is the default editor:

fc -e - [old=new] [string]

In this command:

-e

specifies that you wish make a replacement.

-

(hyphen) indicates that the default editor is to be used.

old=new

specifies that you wish to replace the string defined by old with the new string

defined by new.

string

specifies that the shell should make the change to the most recent command line in

the buffer containing the string of characters specified by string.

The shell also allows you to edit individual command lines at the shell prompt by using a command
set similar to that of the vi editor. For more information on this feature, see the sh(1) reference
page either online or in the Open System Services Shell and Utilities Reference Manual.

Following are examples of fc use.

Displaying Command Lines in the Command History Buffer

To display command lines 15 through 18, enter:

$ fc -l 15 18

15 ls -la

16 pwd

17 cd /u/ben/reports

18 more sales

You can also list the same command lines by specifying command strings instead of line numbers,
as in the following example:

$ fc -l ls more

15 ls -la

42

The OSS Shell

Advertising
This manual is related to the following products: