๐ Csh History#
Overview
Csh shell history allows users to recall previous commands and rerun them by typing only a few quick keystrokes.
Commands#
Event Designators |
|
|---|---|
Cmd |
Description |
!
|
Begin a history substitution
|
!!
|
Previous command
|
!n
|
Command number n in history list
|
!-n
|
n th commnand back from current command
|
!string
|
Most recent command that starts with string
|
!?string[?]
|
Most recent command that contains string
|
^old^new^
|
Quick substitution,
change string old to new in previous command,
and execute modified command
|
Word Substitution |
|
|---|---|
Cmd |
Description |
:0
|
Command name
|
:n
|
Argument number n
|
^
|
First argument
|
$
|
Last argument
|
%
|
Argument matched by a !?string? search
|
:n-m
|
Arguments n through m
|
-m
|
Words 0 through m, same as :0-m
|
:n-
|
Arguments n through next-to-last
|
:n*
|
Arguments n through last; same as n-$
|
*
|
All arguments; same as ^-$ or 1-$
|
History Modifiers |
|
|---|---|
Cmd |
Description |
:p
|
Display command, but donโt execute
|
:s/old/new
|
Substitute string new for old, first instance only
|
:gs/old/new
|
Substitute string new for old, all instances
|
:as/old/new
|
Same as :gs
|
:Gs/old/new
|
Apply the substitution to all words in the command line
|
Usage#
touch test1 test2
echo !:0 !t:1!t:2
touch test1test2
mkdir !t:1!t:2
mv !t:1 !t:2 !m:$
!t:p
touch test1 test2
!t:p:s/test/TEST
touch TEST1 test2
fc -l 189 189
ls -trl Documents
ls -trd !189:$
Documents
echo !189:$:s/Docu/Testa
Testaments
Tip
Usefull to quickly recall the last commandโs argument or the last command [1].
ls -trl file
vi !$
!!
