echo - write arguments to standard output
echo [string ...]
The echo utility will write its arguments to standard output, followed by a newline character. If there are no arguments, only the newline character will be written.
The echo utility will not recognise the -- argument in the manner specified by Guideline 10 of the XBD specification, Utility Syntax Guidelines ; -- will be recognised as a string operand.Implementations will not support any options.
The following operands are supported:
- string
- A string to be written to standard output. If any operand is -n, it will be treated as a string, not an option. The following character sequences will be recognised within any of the arguments:
- \a
- Write an alert character.
- \b
- Write a backspace character.
- \c
- Suppress the newline character that otherwise follows the final argument in the output. All characters following the \c in the arguments will be ignored.
- \f
- Write a form-feed character.
- \n
- Write a newline character.
- \r
- Write a carriage-return character.
- \t
- Write a tab character.
- \v
- Write a vertical-tab character.
- \\
- Write a backslash character.
- \0num
- Write an 8-bit value that is the zero-, one-, two- or three-digit octal number num .
Not used.
None.
The following environment variables affect the execution of echo:
- LANG
- Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
- LC_ALL
- If set to a non-empty string value, override the values of all the other internationalisation variables.
- LC_CTYPE
- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
- LC_MESSAGES
- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
- NLSPATH
- Determine the location of message catalogues for the processing of LC_MESSAGES .
Default.
The echo utility arguments will be separated by single space characters and a newline character will follow the last argument. Output transformations will occur based on the escape sequences in the input; see the OPERANDS section.
Used only for diagnostic messages.
None.
None.
The following exit values are returned:
- 0
- Successful completion.
- >0
- An error occurred.
Default.
It is not possible to use echo portably across all systems that are not XSI-conformant unless both -n (as the first argument) and escape sequences are omitted.The printf utility can be used portably to emulate any of the traditional behaviours of the echo utility as follows:
- The XSI echo is equivalent to:
printf "%b\n" "$*"
- The BSD echo is equivalent to:
if [ "X$1" = "X-n" ] then shift printf "%s" "$*" else printf "%s\n" "$*" fi
New applications are encouraged to use printf instead of echo.
None.
None.
printf.