echo Options and Escape Sequences
echo accepts a number of arguments (see Table A-11).
Table A-11. echo options
Options | Function |
---|---|
| Turns on the interpretation of backslash-escaped characters |
| Turns off the interpretation of backslash-escaped characters on systems where this mode is the default |
| Omits the final newline (same as the |
echo accepts a number of escape sequences that start with a backslash.
These sequences in Table A-12 exhibit
fairly predictable behavior, except for \f
, which on some displays causes a screen clear
while on others it causes a line feed, and it ejects the page on most
printers. \v
is somewhat obsolete; it
usually causes a line feed.
Table A-12. echo escape sequences
Sequence | Character printed |
---|---|
| Alert or Ctrl-G (bell) |
| Backspace or Ctrl-H |
| Omit final newline |
| Escape character (same as |
| Escape character |
| Formfeed or Ctrl-L |
| Newline (not at end of command) or Ctrl-J |
| Return (Enter) or Ctrl-M |
| Tab or Ctrl-I |
| Vertical Tab or Ctrl-K |
| The eight-bit character whose value is the octal
(base-8) value |
| The eight-bit character whose value is the octal
(base-8) value |
| The eight-bit character whose value is the
hexadecimal (base-16) value |
\\ | Single backslash |
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.
Get bash Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.