并且不要忘记bash中出色的历史记录扩展快捷方式。1个
我会在手册页中发布一些节选,以防您没有在手臂上刺青(或记住)。
Event Designators
An event designator is a reference to a command line entry in the his‐
tory list.
! Start a history substitution, except when followed by a blank,
newline, carriage return, = or ( (when the extglob shell option
is enabled using the shopt builtin).
!n Refer to command line n.
!-n Refer to the current command line minus n.
!! Refer to the previous command. This is a synonym for `!-1'.
!string
Refer to the most recent command starting with string.
!?string[?]
Refer to the most recent command containing string. The trail‐
ing ? may be omitted if string is followed immediately by a new‐
line.
^string1^string2^
Quick substitution. Repeat the last command, replacing string1
with string2. Equivalent to ``!!:s/string1/string2/'' (see Mod‐
ifiers below).
!# The entire command line typed so far.
我经常使用该功能来引用上一个命令的最后一个“单词”。例如,
mkdir /foo/shmoo/adir.horribilus.foo
cp file1 file2 file3 file4 !$
ls -l !$
在这两种情况下,都是!$
matchs /foo/shmoo/adir.horribilus.foo
。
1 ...取自csh。为了减轻bash功能盗窃的范围,bash手册页说
The shell supports a history expansion feature that is similar to the
history expansion in csh.
因此,这是“相似的”。任何一种都可能闯入csh
或tcsh
。或您不使用的任何csh后代,因为它不如bash
。