同步阅读进度,多语言翻译,过滤屏幕蓝光,评论分享,更多完整功能,更好读书体验,试试 阅读 ‧ 电子书库
echo
As we've seen countless times in this book, echo simply prints its arguments to standard output. Now we'll explore the command in greater detail.
Options to echo
echo accepts a few dash options, listed in Table 7-2.
Table 7-2. echo options
Option
Function
-e
Turns on the interpretation of backslash-escaped characters
-E
Turns off the interpretation of backslash-escaped characters on systems where this mode is the default
-n
Omits the final newline (same as the \c escape sequence)
echo escape sequences
echo accepts a number of escape sequences that start with a backslash.[2] They are listed in Table 7-3.
These sequences exhibit fairly predictable behavior, except for \f: on some displays, it causes a screen clear, while on others it causes a line feed. It ejects the page on most printers. \v is somewhat obsolete; it usually causes a line feed.
Table 7-3. echo escape sequences
Sequence
Character printed
\a
ALERT or CTRL-G (bell)
\b
BACKSPACE or CTRL-H
\c
Omit final NEWLINE
\e
Escape character (same as \E)
\E
Escape character[3]
\f
FORMFEED or CTRL-L
\n
NEWLINE (not at end of command) or CTRL-J
\r
RETURN (ENTER) or CTRL-M
\t
TAB or CTRL-I
\v
VERTICAL TAB or CTRL-K
\ n
ASCII character with octal (base-8) value n, where n is 1 to 3 digits
\0nnn
The eight-bit character whose value is the octal (base-8) value nnn where nnn is 1 to 3 digits
\xHH
The eight-bit character whose value is the hexadecimal (base-16) value HH (one or two digits)
\\
Single backslash
[3] Not available in versions of bash prior to 2.0.
The \n, \0, and \x sequences are even more device-dependent and can be used for complex I/O, such as cursor control and special graphics characters.
请支持我们,让我们可以支付服务器费用。
使用微信支付打赏