简体   繁体   English

Linux Shell printf-如何打印%?

[英]Linux Shell printf - How to print %?

I am trying to print % with the printf command. 我正在尝试使用printf命令打印 Unfortunately the backslash as escape character is not working. 不幸的是,反斜杠作为转义字符不起作用。

Use %% to print a literal % character: 使用%%打印原义%字符:

$ printf '%%\n'
%

man printf describes the behaviour of the printf executable. man printf描述了printf可执行文件的行为。 Some shells (eg bash) provide their own implementation - in this case, some extra information can be found in man bash . 一些shell(例如bash)提供了自己的实现-在这种情况下,可以在man bash找到一些额外的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM