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:
- 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:
- Write an alert character.
- Write a backspace character.
- Suppress the newline character that otherwise follows the final argument in the output. All characters following the \c in the arguments will be ignored.
- Write a form-feed character.
- Write a newline character.
- Write a carriage-return character.
- Write a tab character.
- Write a vertical-tab character.
- Write a backslash character.
- Write an 8-bit value that is the zero-, one-, two- or three-digit octal number num .
The following environment variables affect the execution of echo:
- 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.
- If set to a non-empty string value, override the values of all the other internationalisation variables.
- 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).
- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
- Determine the location of message catalogues for the processing of LC_MESSAGES .
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.
The following exit values are returned:
- Successful completion.
- An error occurred.
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.