Linux命令之感叹号 !

刚才输入命令 echo "This is file content, over!" > filename 竟然会出错,提示:

bash:  !": event not found

原来字符串中的!会被解析。如果不出错的话呢,转义!就可以了,如 \! ,

或者把双引号改成单引号也行。

Google了下错误信息,找到如下内容:

Message bash: !__: event not found
Notes  When you type a word preceeded by an "!", bash thinks you want to recall a previous command or "event". The message indicates no matching event was found in your recent command history. You can suppress the special meaning of ! by quoting it, for example: \!

这段英文的大概意思就是说 !的作用就是调用之前的命令或事件。
比如 我之前输入了一条命令 touch aaa bbb ,然后又删了 rm aaa bbb,如果我又想重新创建文件aaa bbb 我直接输入 !touch 就可以了,该命令就会重复执行上一次touch命令,即touch aaa bbb 
 
参考文献: 

转载于:https://www.cnblogs.com/realwall/archive/2011/11/21/2257434.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值