echo - Write arguments to standard output
Format
echo argument ...
tcsh shell: echo [-n] word ...
Description
echo writes its arguments, which are specified with the
argument argument, to standard output. echo accepts these
C-style escape sequences:
- \a
- Bell
- \b
- Backspace
- \c
- Removes any following characters, including \n and \r.
- \f
- Form feed
- \n
- Newline
- \r
- Carriage return
- \t
- Horizontal tab
- \v
- Vertical tab
- \0num
- The byte with the numeric value that is specified by the zero to three-digit octal num.
- \-
- Backslash
echo follows the final
argument with a newline unless it finds \c
in the
arguments. Arguments are subject to standard argument manipulation.
In the tcsh shell, echo writes each word to the shell's standard output, which is separated by spaces and terminated with a newline.
tcsh echo accepts these
C-style escape sequences:
- \a
- Bell
- \b
- Backspace
- \e
- Escape
- \f
- Form feed
- \n
- Newline
- \r
- Carriage return
- \t
- Horizontal tab
- \v
- Vertical tab
- \nnn
- The EBCDIC character corresponding to the octal number nnn
For more information, see tcsh - Invoke a C shell.
Examples
- One important use of echo is to expand file names on the command line, as in:
This displays the names of all files with names ending in .c or .h, typically C source and include (header) files. echo displays the names on a single line. If there are no file names in the working directory that end in .c or .h, echo displays the string *.[ch].echo *.[ch]
- echo is also convenient for passing
small amounts of input to a filter
or a file:
echo 'this is\nreal handy' > testfile
Usage notes
echo is a built-in shell command.
Localization
echo uses
the following localization environment variables:
- LANG
- LC_ALL
- LC_MESSAGES
- LC_SYNTAX
- NLSPATH
Exit value
echo always
returns the following exit status value:
0
- Successful completion.
Portability
POSIX.2, UNIX System V.
The POSIX standard does not include escape sequences, so a strictly conforming application cannot use them. printf is suggested as a replacement.
Related information
sh, tcsh