2019-03-31 09:05:09 +00:00
|
|
|
.. _cmd-echo:
|
|
|
|
|
2018-12-17 01:39:33 +00:00
|
|
|
echo - display a line of text
|
2019-01-03 04:10:47 +00:00
|
|
|
=============================
|
2018-12-17 01:39:33 +00:00
|
|
|
|
2018-12-18 01:58:24 +00:00
|
|
|
Synopsis
|
|
|
|
--------
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2019-09-17 09:59:04 +00:00
|
|
|
::
|
2018-12-18 01:58:24 +00:00
|
|
|
|
2019-09-17 09:59:04 +00:00
|
|
|
echo [OPTIONS] [STRING]
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 02:44:30 +00:00
|
|
|
Description
|
2019-01-03 04:10:47 +00:00
|
|
|
-----------
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
``echo`` displays a string of text.
|
2018-12-16 21:08:41 +00:00
|
|
|
|
|
|
|
The following options are available:
|
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``-n``, Do not output a newline
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``-s``, Do not separate arguments with spaces
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``-E``, Disable interpretation of backslash escapes (default)
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``-e``, Enable interpretation of backslash escapes
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2020-08-19 17:00:20 +00:00
|
|
|
Unlike other shells, this echo accepts ``--`` to signal the end of the options.
|
|
|
|
|
2018-12-19 02:44:30 +00:00
|
|
|
Escape Sequences
|
2019-01-03 04:10:47 +00:00
|
|
|
----------------
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
If ``-e`` is used, the following sequences are recognized:
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``\`` backslash
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``\a`` alert (BEL)
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``\b`` backspace
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``\c`` produce no further output
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``\e`` escape
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``\f`` form feed
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``\n`` new line
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``\r`` carriage return
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``\t`` horizontal tab
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``\v`` vertical tab
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``\0NNN`` byte with octal value NNN (1 to 3 digits)
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 20:02:45 +00:00
|
|
|
- ``\xHH`` byte with hexadecimal value HH (1 to 2 digits)
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 02:44:30 +00:00
|
|
|
Example
|
2019-01-03 04:10:47 +00:00
|
|
|
-------
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2018-12-19 03:14:04 +00:00
|
|
|
::
|
|
|
|
|
2020-08-19 17:00:20 +00:00
|
|
|
> echo 'Hello World'
|
|
|
|
Hello World
|
2018-12-19 03:14:04 +00:00
|
|
|
|
2020-08-26 16:29:03 +00:00
|
|
|
> echo -e 'Top\nBottom'
|
2020-08-19 17:00:20 +00:00
|
|
|
Top
|
|
|
|
Bottom
|
2018-12-19 03:14:04 +00:00
|
|
|
|
2020-08-19 17:00:20 +00:00
|
|
|
> echo -- -n
|
|
|
|
-n
|
2020-03-01 12:43:14 +00:00
|
|
|
|
|
|
|
See Also
|
|
|
|
--------
|
|
|
|
|
|
|
|
- the :ref:`printf <cmd-printf>` command, for more control over output formatting
|