Linux: 命令:echo

软件

[root@10 ~]# which echo
/usr/bin/echo
[root@10 ~]# file /usr/bin/echo
/usr/bin/echo: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x
86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=f2bf59d1989e25e8a79d3ab29c1b5bd54b874427, stripped
[root@10 ~]# rpm -qf /usr/bin/echo
coreutils-8.30-12.el8.x86_64

使用说明

显示一行字符串。命令格式:
echo [选项]… [串]…
echo LONG-OPTION
输出"串“到标准输出。
-n do not output the trailing newline 不显示末尾的换行符
-e enable interpretation of backslash escapes /// 转义字符
-E disable interpretation of backslash escapes (default)、、、、不解释转义字符
–help display this help and exit 、、、显示帮助
–version 显示版本信息
If -e is in effect, the following sequences are recognized:
\ backslash
\a alert (BEL)
\b backspace
\c produce no further output
\e escape
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\0NNN byte with octal value NNN (1 to 3 digits)
\xHH byte with hexadecimal value HH (1 to 2 digits)
注意,在自己的机器上使用echo时,一定要确保echo的版本;因为这个小巧的程序,实现起来比较简单,所以有很多版本。
AUTHOR
Written by Brian Fox and Chet Ramey.

REPORTING BUGS
GNU coreutils online help: https://www.gnu.org/software/coreutils/
Report echo translation bugs to https://translationproject.org/team/

需要注意的问题

https://wiki.bash-hackers.org/commands/builtin/echo
https://stackoverflow.com/questions/4435853/echo-outputs-e-parameter-in-bash-scripts-how-can-i-prevent-this
建议为了兼容性,轻易不要使用echo,而是使用printf。

猜你喜欢

转载自blog.csdn.net/qq_36428903/article/details/125463304