csh.1 (2010 09)
c
csh(1) csh(1)
You can refer to previous events by event number (such as
!10 for event 10), relative event location
(such as
!-2 for the second previous event), full or partial command name (such as
!d for the last event
using a command with initial character
d), and string expression (such as
!?mic? referring to an event
containing the characters
mic).
These forms, without further modification, simply reintroduce the words of the specified events, each
separated by a single blank. As a special case,
!! is a re-do; it refers to the previous command.
To select words from a command, use a colon (
:) and a designator for the desired words after the event
specification. The words of an input line are numbered from zero. The basic word designators are:
0 First word (i.e., the command name itself).
nnth word.
^ First argument. (This is equivalent to 1
.)
$ Last word.
a
-b Range of words from a through b. Special cases are
-y, an abbreviation for ‘‘word 0 through
word y’’; and x
-, which means ‘‘word x up to, but not including, word
$’’.
* Range from the second word through the last word.
% Used with a search sequence to substitute the immediately preceding matching word.
The colon separating the command specification from the word designator can be omitted if the argument
selector begins with a
ˆ, $, *, -,or%.
After word designator can be followed by a sequence of modifiers, each preceded by a colon. The follow-
ing modifiers are defined:
h Use only the first component of a path name by removing all following components.
r Use the root file name by removing any trailing suffix (.xxx).
e Use the file name’s trailing suffix (
.xxx) by removing the root name.
s/l/r
substitute the value of r for the value l in the indicated command.
t Use only the final file name of a path name by removing all leading path name components.
& Repeat the previous substitution.
p Print the new command but do not execute it.
q Quote the substituted words, preventing further substitutions.
x Like q, but break into words at blanks, tabs and newlines.
g Use a global command as a prefix to another modifier to cause the specified change to be made
globally. All words in the command are changed, one change per word, and each string
enclosed in single quotes (’) or double quotes ( " ) is treated as a single word.
Unless preceded by a
g, the modification is applied only to the first modifiable word. An error results if a
substitution is attempted and cannot be completed (i.e., if you ask for a substitution of !11 on a history
buffer containing only 10 commands).
The left hand side of substitutions are strings; not regular expressions in the sense of HP-UX editors.
Any character can be used as the delimiter in place of a slash (
/). Use a backslash to quote a delimiter
character if it is used in the l or r string. The character & in the right-hand side is replaced by the text
from the left. A \ also quotes &. A null l string uses the previous string either from an l or from a con-
textual scan string s in !?s?. The trailing delimiter in the substitution can be omitted if a new-line char-
acter follows immediately, as may the trailing ? in a contextual scan.
A history reference can be given without an event specification (as in
!$). In this case, the reference is to
the previous command unless a previous history reference occurred on the same line, in which case this
form repeats the previous reference. Thus
!?foo?ˆ !$
gives the first and last arguments from the command matching ?foo?.
A special abbreviation of a history reference occurs when the first non-blank character of an input line is
a circumflex (
ˆ). This is equivalent to !:sˆ, providing a convenient shorthand for substitutions on the
HP-UX 11i Version 3: September 2010 − 9 − Hewlett-Packard Company 9