1ECHO(1P)                   POSIX Programmer's Manual                  ECHO(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       echo — write arguments to standard output
14

SYNOPSIS

16       echo [string...]
17

DESCRIPTION

19       The echo utility writes its arguments to standard output, followed by a
20       <newline>.  If there are no arguments, only the <newline> is written.
21

OPTIONS

23       The  echo  utility  shall not recognize the "−−" argument in the manner
24       specified  by  Guideline  10  of  the  Base   Definitions   volume   of
25       POSIX.1‐2008,  Section  12.2,  Utility Syntax Guidelines; "−−" shall be
26       recognized as a string operand.
27
28       Implementations shall not support any options.
29

OPERANDS

31       The following operands shall be supported:
32
33       string    A string to be written to standard output. If the first oper‐
34                 and  is  −n,  or if any of the operands contain a <backslash>
35                 character, the results are implementation-defined.
36
37                 On XSI-conformant systems, if the first  operand  is  −n,  it
38                 shall  be  treated  as a string, not an option. The following
39                 character sequences shall  be  recognized  on  XSI-conformant
40                 systems within any of the arguments:
41
42                 \a      Write an <alert>.
43
44                 \b      Write a <backspace>.
45
46                 \c      Suppress  the  <newline>  that  otherwise follows the
47                         final argument in the output. All characters  follow‐
48                         ing the '\c' in the arguments shall be ignored.
49
50                 \f      Write a <form-feed>.
51
52                 \n      Write a <newline>.
53
54                 \r      Write a <carriage-return>.
55
56                 \t      Write a <tab>.
57
58                 \v      Write a <vertical-tab>.
59
60                 \\      Write a <backslash> character.
61
62                 \0num   Write  an  8-bit value that is the zero, one, two, or
63                         three-digit octal number num.
64

STDIN

66       Not used.
67

INPUT FILES

69       None.
70

ENVIRONMENT VARIABLES

72       The following environment variables shall affect the execution of echo:
73
74       LANG      Provide a default value for  the  internationalization  vari‐
75                 ables  that are unset or null. (See the Base Definitions vol‐
76                 ume of POSIX.1‐2008, Section 8.2, Internationalization  Vari‐
77                 ables  for  the  precedence of internationalization variables
78                 used to determine the values of locale categories.)
79
80       LC_ALL    If set to a non-empty string value, override  the  values  of
81                 all the other internationalization variables.
82
83       LC_CTYPE  Determine  the  locale for the interpretation of sequences of
84                 bytes of text data as characters (for example, single-byte as
85                 opposed to multi-byte characters in arguments).
86
87       LC_MESSAGES
88                 Determine the locale that should be used to affect the format
89                 and contents  of  diagnostic  messages  written  to  standard
90                 error.
91
92       NLSPATH   Determine the location of message catalogs for the processing
93                 of LC_MESSAGES.
94

ASYNCHRONOUS EVENTS

96       Default.
97

STDOUT

99       The echo utility arguments shall be separated by single <space> charac‐
100       ters  and a <newline> character shall follow the last argument.  Output
101       transformations shall occur based on the escape sequences in the input.
102       See the OPERANDS section.
103

STDERR

105       The standard error shall be used only for diagnostic messages.
106

OUTPUT FILES

108       None.
109

EXTENDED DESCRIPTION

111       None.
112

EXIT STATUS

114       The following exit values shall be returned:
115
116        0    Successful completion.
117
118       >0    An error occurred.
119

CONSEQUENCES OF ERRORS

121       Default.
122
123       The following sections are informative.
124

APPLICATION USAGE

126       It is not possible to use echo portably across all POSIX systems unless
127       both −n (as the first argument) and escape sequences are omitted.
128
129       The printf utility can be used portably to emulate any  of  the  tradi‐
130       tional  behaviors of the echo utility as follows (assuming that IFS has
131       its standard value or is unset):
132
133        *  The historic System V echo and the requirements on XSI  implementa‐
134           tions in this volume of POSIX.1‐2008 are equivalent to:
135
136               printf "%b\n$*"
137
138        *  The BSD echo is equivalent to:
139
140               if [ "X$1" = "X−n" ]
141               then
142                   shift
143                   printf "%s$*"
144               else
145                   printf "%s\n$*"
146               fi
147
148       New applications are encouraged to use printf instead of echo.
149

EXAMPLES

151       None.
152

RATIONALE

154       The echo utility has not been made obsolescent because of its extremely
155       widespread use in historical applications. Conforming applications that
156       wish  to do prompting without <newline> characters or that could possi‐
157       bly be expecting to echo a −n, should use the  printf  utility  derived
158       from the Ninth Edition system.
159
160       As  specified,  echo  writes its arguments in the simplest of ways. The
161       two different historical versions of echo vary in fatally  incompatible
162       ways.
163
164       The  BSD  echo checks the first argument for the string −n which causes
165       it to suppress the <newline> that  would  otherwise  follow  the  final
166       argument in the output.
167
168       The  System  V  echo  does  not  support any options, but allows escape
169       sequences within its operands, as described for XSI implementations  in
170       the OPERANDS section.
171
172       The  echo  utility does not support Utility Syntax Guideline 10 because
173       historical applications depend on echo to echo all  of  its  arguments,
174       except for the −n option in the BSD version.
175

FUTURE DIRECTIONS

177       None.
178

SEE ALSO

180       printf
181
182       The  Base  Definitions  volume  of POSIX.1‐2008, Chapter 8, Environment
183       Variables, Section 12.2, Utility Syntax Guidelines
184
186       Portions of this text are reprinted and reproduced in  electronic  form
187       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
188       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
189       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
190       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
191       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
192       event of any discrepancy between this version and the original IEEE and
193       The  Open Group Standard, the original IEEE and The Open Group Standard
194       is the referee document. The original Standard can be  obtained  online
195       at http://www.unix.org/online.html .
196
197       Any  typographical  or  formatting  errors that appear in this page are
198       most likely to have been introduced during the conversion of the source
199       files  to  man page format. To report such errors, see https://www.ker
200       nel.org/doc/man-pages/reporting_bugs.html .
201
202
203
204IEEE/The Open Group                  2013                             ECHO(1P)
Impressum