- 论坛徽章:
- 0
|
对于bash,命令行中的!可能是这样的意思
!!表示上一条命令,!xx表示上一条同类命令(比如前面执行过ls 1,!ls就是ls 1)
而且还有个效果是不光输出命令结果,在第一行还输出命令替换后的实际执行命令
- [root@host tmp]# aaa
- -bash: aaa: command not found
- [root@host tmp]# !!
- aaa
- -bash: aaa: command not found
- [root@host tmp]# bbb
- -bash: bbb: command not found
- [root@host tmp]# !bbb
- bbb
- -bash: bbb: command not found
- [root@host tmp]# !bbb 1
- bbb 1
- -bash: bbb: command not found
- [root@host tmp]# !!bbb 1
- bbb 1bbb 1
- -bash: bbb: command not found
- [root@host tmp]# ls x
- ls: x: 没有那个文件或目录
- [root@host tmp]# !!
- ls x
- ls: x: 没有那个文件或目录
- [root@host tmp]# !ls y
- ls x y
- ls: x: 没有那个文件或目录
- ls: y: 没有那个文件或目录
- [root@host tmp]# !!ls z
- ls x yls z
- ls: x: 没有那个文件或目录
- ls: yls: 没有那个文件或目录
- ls: z: 没有那个文件或目录
复制代码
这样就能理解楼主的 echo "AAAAAA!"为什么报-bash: !": event not found
翻译过来就是"这样的同类命令找不到
如下,报的就是xxx"这样的同类命令没找到:
- [root@host tmp]# echo "xxxx!xxx"
- -bash: !xxx": event not found
- [root@host tmp]#
复制代码
像这样,就不会报错,因为前面有执行过一个同类ls命令。echo "xxx!ls在命令替换过后变成echo "xxxls zzz
- [root@host tmp]# ls zzz
- ls: zzz: 没有那个文件或目录
- [root@host tmp]# echo "xxx!ls
- echo "xxxls zzz
- >
复制代码
[ 本帖最后由 ywlscpl 于 2009-1-24 15:04 编辑 ] |
|