码迷,mamicode.com
首页 > 系统相关 > 详细

Linux的!(感叹号)

时间:2021-01-02 10:56:08      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:lin   历史   命令   linux   com   world   没有   输出   添加   

echo "Hello World!" > index.html时发现会回显执行的命令,且index.html文件中没有!号
使用echo "Hello World\!" > index.html时发现连同\一起输出
解决办法,不使用双引号,改用单引号echo ‘Hello World!‘ > index.html
或者感叹号后添加空格echo "Hello World! " > index.html

出现这个问题并不是因为转义,而是感叹号还有特殊用法
!号用于执行历史命令
# history 1 ping www.baidu.com 2 ls 3 history
->可使用!1执行第一条命令
!1 ping www.baidu.com ...
->使用!-1或!!执行倒数第一条命令(因为上方!1执行了第一条命令,所以!-1还是ping www.baidu.com)
!-1 ping www.baidu.com ...
->使用!?s执行最近一次命令中包含s的命令
!?s ls ...
->使用!$代替上一个命令中的参数
ping -6 www.baidu.com ... ping !$ ping www.baidu.com ...

Linux的!(感叹号)

标签:lin   历史   命令   linux   com   world   没有   输出   添加   

原文地址:https://www.cnblogs.com/DRMCC/p/14205089.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!