O'Reilly logo

Using csh & tcsh by Paul DuBois

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Event Modifiers

Following a word designator (or an event specifier if there is no designator) you can add an event modifier:

!event:words:modifiers
!event:modifiers

Modifiers change the way an event is treated. If you add :p to an event reference, the event is printed (echoed) but not executed. Other modifiers change the text of the recalled event or words in some way. For instance, adding :s/a/b changes a to b in the command line. This feature is useful for fixing mistakes or modifying an argument. Possible modifiers are listed in Table 6-5.

Table 6-5. History Reference Modifiers

Modifier

Description

p

Print resulting command without executing it

s/old/new/

Perform substitution, replacing old with new

&

Repeat previous s substitution

r

Root of filename (everything but extension following dot)

e

Extension of filename (suffix following dot)

h

Head of pathname (all but last component)

t

Tail of pathname (last component)

q

Quote words (prevents filename pattern expansion)

x

Like q but break into words at whitespace

u

Make first lowercase letter uppercase (tcsh only)

l

Make first uppercase letter lowercase (tcsh only)

g

Apply modifier following g globally to each word

a

Apply modifier(s) following a as many times as possible to a word. If used with g, a is applied to all words. (tcsh only)

Modifiers vary a great deal in terms of their general usefulness. I find that :s and :p are the most valuable. The following sections discuss :p, the substitution modifier :s (along with the repetition modifiers :g, :a, and :&

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required