如何安装“!!”命令?

如何安装“!!”命令?

我试图!!在新安装的 debian 上使用,但出现以下错误:

$ sudo !!
sudo: !!: command not found

我能利用吗!!

另外,我可以调用什么!!以便我实际上可以通过谷歌搜索有关它的信息?

答案1

您正在引用历史当你引用时你的 shell 的功能!!

我不确定你用的是什么外壳。从man bash

HISTORY EXPANSION
   The  shell  supports a history expansion feature that is similar to the
   history expansion in csh.
...
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'.

你的 shell 历史中有什么吗?当您输入history命令时,您会得到任何输出吗?

我无法复制您看到的错误:

~$ ls -l | head -1
total 54324
~$ sudo !!
sudo ls -l | head -1
total 54324
~$ 

相关内容