在线手册中有关每个命令的信息很多。在放弃并发布问题之前总是值得一看。
man echo
说明允许的转义序列。这是摘录。
If -e is in effect, the following sequences are recognized:
\0NNN the character whose ASCII code is NNN (octal)
\\ backslash
\a alert (BEL)
\b backspace
\c produce no further output
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
因此\ x86只是不正确。它必须是八进制的,并将字符串放在双引号中,否则它将由外壳程序解释。
例:
$ echo -e -n "\033\07\017" >tf
$ od -c tf
0000000 033 \a 017
0000003
编辑1
正如Ouki提醒我的那样,echo也是内置的shell,因此该信息在bash的手册页中man bash
;这是相关的部分。但是,请在字符串两边使用引号 "
来阻止外壳解释反斜杠。
echo [-neE] [arg ...]
Output the args, separated by spaces, followed by a newline. The return status is always
0. If -n is specified, the trailing newline is suppressed. If the -e option is given,
interpretation of the following backslash-escaped characters is enabled. The -E option
disables the interpretation of these escape characters, even on systems where they are
interpreted by default. The xpg_echo shell option may be used to dynamically determine
whether or not echo expands these escape characters by default. echo does not interpret --
to mean the end of options. echo interprets the following escape sequences:
\a alert (bell)
\b backspace
\c suppress further output
\e an escape character
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\0nnn the eight-bit character whose value is the octal value nnn (zero to three octal dig‐
its)
\xHH the eight-bit character whose value is the hexadecimal value HH (one or two hex dig‐
its)