Và đừng quên các phím tắt mở rộng lịch sử tuyệt vời trong bash. 1
Tôi đang đăng một số trích đoạn từ trang chủ, trong trường hợp bạn không xăm chúng trên cánh tay (hoặc ghi nhớ chúng).
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.
Tôi thường xuyên sử dụng khả năng để chỉ 'từ' cuối cùng của lệnh trước đó. Ví dụ,
mkdir /foo/shmoo/adir.horribilus.foo
cp file1 file2 file3 file4 !$
ls -l !$
Trong cả hai trường hợp ở đây, các !$trận đấu /foo/shmoo/adir.horribilus.foo.
1 ... được lấy từ csh. Để giảm thiểu phạm vi trộm cắp tính năng của bash, trang bash man nói
The shell supports a history expansion feature that is similar to the
history expansion in csh.
Vì vậy, nó "tương tự". Bất kỳ điều này có thể đột nhập cshhoặc tcsh. Hoặc bất cứ điều gì csh hậu duệ bạn không sử dụng do thực tế là nó không tuyệt vời như bash.