linux 中printf命令输出感叹号!

Posted 小鲨鱼2018

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 中printf命令输出感叹号!相关的知识,希望对你有一定的参考价值。

 

001、测试

[root@PC1 test01]# printf "abcd\\n"          ## 输出abcd并换行
abcd
[root@PC1 test01]# printf "ab!cd\\n"         ## 不能正常的输出感叹号
-bash: !cd\\n": event not found
[root@PC1 test01]# printf "ab\\!cd\\n"        ## 加转义字符也不行
ab\\!cd

 

002、正确做法

[root@PC1 test01]# printf "%s\\n" abcd\\!
abcd!
[root@PC1 test01]# printf "%s\\n" ab\\!cd       ## 利用printf命令输出感叹号
ab!cd

 

或者:

[root@PC1 test01]# printf "%s\\n" \'ab!cd\'
ab!cd

 

以上是关于linux 中printf命令输出感叹号!的主要内容,如果未能解决你的问题,请参考以下文章