我刚刚了解到 Linux 有一个sudo !!命令,它实际上适用sudo于最后输入的命令。我从来没有听说过。
这是通用控件吗?我在哪里可以找到有关它的文档?
cjc*_*cjc 36
这只是 bash 的快捷方式。sudo!!顺便说一下,它不是。它是sudo !!(注意空格)。
的!!在bash基本上是前一命令的扩展。
看看 bash 手册页的“历史扩展”部分:
http://www.gnu.org/software/bash/manual/bashref.html#Event-Designators
Kev*_*vin 29
它实际上sudo !!,它是由命令的sudo,与你可能熟悉,和事件标志,!!,这是指最后输入的命令。您可以在bash手册页的Event Designators部分下找到更多信息。
Event Designators
An event designator is a reference to a command line entry in the his?
tory list. Unless the reference is absolute, events are relative to
the current position in the history 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 minus n.
!! Refer to the previous command. This is a synonym for `!-1'.
!string
Refer to the most recent command preceding the current position
in the history list starting with string.
!?string[?]
Refer to the most recent command preceding the current postition
in the history list containing string. The trailing ? may be
omitted if string is followed immediately by a newline.
^string1^string2^
Quick substitution. Repeat the previous command, replacing
string1 with string2. Equivalent to ``!!:s/string1/string2/''
(see Modifiers below).
!# The entire command line typed so far.
Run Code Online (Sandbox Code Playgroud)