Moving Mesh
论坛搜索:

主页 » Software » Linux » 咨询一条 bash 命令
咨询一条 bash 命令 [帖号 #1040] 五, 19 三月 2010 10:15 下一楼
cai_zn  现在不在线 cai_zn
发帖数: 87
注册时间: 十月 2007
Member
有哪位大大知道为什么在 bash 里输入
$ !!

能执行上一条命令么?
回复: 咨询一条 bash 命令 [帖号 #1041 是对于帖子 #1040 的回复 ] 一, 22 三月 2010 23:30 楼上下一楼
robertliecn  现在不在线 robertliecn
发帖数: 259
注册时间: 七月 2007
Senior Member
说明书中是这么解释的:

The POSIX `PS1' and `PS2' expansions of `!' to the history number and `!!' to `!' are enabled, and parameter expansion is performed on the values of `PS1' and `PS2' regardless of the setting of the `promptvars' option.
回复: 咨询一条 bash 命令 [帖号 #1042 是对于帖子 #1041 的回复 ] 日, 28 三月 2010 02:25 楼上下一楼
cai_zn  现在不在线 cai_zn
发帖数: 87
注册时间: 十月 2007
Member
我也在 man bash 里找到了:
引用:
   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.

回复: 咨询一条 bash 命令 [帖号 #1043 是对于帖子 #1042 的回复 ] 日, 28 三月 2010 02:26 楼上
cai_zn  现在不在线 cai_zn
发帖数: 87
注册时间: 十月 2007
Member
这几个功能原来都不知道呢~
下一个主题:对自己的 Linux 知识有信心的朋友们来此看看
上一个主题:发帖必看
转至论坛:
  


当前时间: 六 9月 4 15:17:29 EDT 2010

生成本页面共花费时间:0.02768 秒。
.:: 联系 :: 主页 ::.

Powered by: FUDforum 2.8.1.
Copyright ©2001-2009 FUDforum Bulletin Board Software