r

edit and re-execute previous command 

KornShell Built-in


SYNOPSIS

r [old=new] [specifier]


DESCRIPTION

The r command (a built-in KornShell alias) re-executes a command you ran previously, possibly editing it first. Commands are obtained from your command history file; see fc and sh for more details.

The specifier tells which command you want to re-execute. It can have any of the following forms:

An unsigned number (n

r run the command with that number.

A negative number (-n

r runs the command that came n commands before the current one.

A character string (x

r runs the most recent command beginning with x.

If no specifier is given, r runs the most recent command.

The old=new feature lets you edit a command before running it. old and new must be character strings. r replaces the first occurrence of old in the command arguments with new and then re-executes the command.


EXAMPLES

r cp

runs the most recently executed command beginning with the characters cp. The cp could be the whole command name or it could be part of a longer command name (for example, cpio).

cp file1 /dir
r 1=2
r 2=3

This is equivalent to

cp file1 /dir
cp file2 /dir
cp file3 /dir

Compare this with

cp file1 /dir/file1
r 1=2

which is equivalent to

cp file1 /dir/file1
cp file2 /dir/file1

Since r only replaces the first occurrence of the old string 1, the second 1 does not change. This shows that you have to be careful when you use the substitution feature.

r is a built-in MKS KornShell alias, defined with

alias r='fc -s'

ENVIRONMENT VARIABLES

HISTFILE 

contains the path name of the history file.

HISTSIZE 

gives the maximum number of previous commands that are accessible.


DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

1 

Failure due to any of the following:

— missing history file
— inability to find the desired command in the history file
2 

Failure due to an invalid command line option or argument.


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0. UNIX systems with the KornShell. Windows 7. Windows Server 2008 R2. Windows 8. Windows Server 2012. Windows 10. Windows Server 2016.


NOTE

This is an alias built into the MKS KornShell.


AVAILABILITY

PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
PTC Integrity


SEE ALSO

Commands:
alias, fc, history, sh

Using the MKS KornShell


PTC MKS Toolkit 10.1 Documentation Build 15.