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

NAME

12       echo - write arguments to standard output
13

SYNOPSIS

15       echo [string ...]
16

DESCRIPTION

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

OPTIONS

22       The  echo  utility  shall not recognize the "--" argument in the manner
23       specified  by  Guideline  10  of  the  Base   Definitions   volume   of
24       IEEE Std 1003.1-2001,  Section  12.2,  Utility  Syntax Guidelines; "--"
25       shall be recognized as a string operand.
26
27       Implementations shall not support any options.
28

OPERANDS

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

STDIN

77       Not used.
78

INPUT FILES

80       None.
81

ENVIRONMENT VARIABLES

83       The following environment variables shall affect the execution of echo:
84
85       LANG   Provide a default value for the  internationalization  variables
86              that  are  unset  or  null.  (See the Base Definitions volume of
87              IEEE Std 1003.1-2001, Section  8.2,  Internationalization  Vari‐
88              ables  for the precedence of internationalization variables used
89              to determine the values of locale categories.)
90
91       LC_ALL If set to a non-empty string value, override the values  of  all
92              the other internationalization variables.
93
94       LC_CTYPE
95              Determine  the  locale  for  the  interpretation of sequences of
96              bytes of text data as characters (for  example,  single-byte  as
97              opposed to multi-byte characters in arguments).
98
99       LC_MESSAGES
100              Determine  the  locale  that should be used to affect the format
101              and contents of diagnostic messages written to standard error.
102
103       NLSPATH
104              Determine the location of message catalogs for the processing of
105              LC_MESSAGES .
106
107

ASYNCHRONOUS EVENTS

109       Default.
110

STDOUT

112       The  echo utility arguments shall be separated by single <space>s and a
113       <newline> shall follow the last argument.  Output transformations shall
114       occur based on the escape sequences in the input. See the OPERANDS sec‐
115       tion.
116

STDERR

118       The standard error shall be used only for diagnostic messages.
119

OUTPUT FILES

121       None.
122

EXTENDED DESCRIPTION

124       None.
125

EXIT STATUS

127       The following exit values shall be returned:
128
129        0     Successful completion.
130
131       >0     An error occurred.
132
133

CONSEQUENCES OF ERRORS

135       Default.
136
137       The following sections are informative.
138

APPLICATION USAGE

140       It is not possible to use echo portably across all POSIX systems unless
141       both -n (as the first argument) and escape sequences are omitted.
142
143       The  printf  utility  can be used portably to emulate any of the tradi‐
144       tional behaviors of the echo utility as follows (assuming that IFS  has
145       its standard value or is unset):
146
147        * The  historic  System V echo and the requirements on XSI implementa‐
148          tions in this volume of IEEE Std 1003.1-2001 are equivalent to:
149
150
151          printf "%b\n" "$*"
152
153        * The BSD echo is equivalent to:
154
155
156          if [ "X$1" = "X-n" ]
157          then
158              shift
159              printf "%s" "$*"
160          else
161              printf "%s\n" "$*"
162          fi
163
164       New applications are encouraged to use printf instead of echo.
165

EXAMPLES

167       None.
168

RATIONALE

170       The echo utility has not been made obsolescent because of its extremely
171       widespread  use  in  historical  applications.  Conforming applications
172       that wish to do prompting without <newline>s or that could possibly  be
173       expecting  to echo a -n, should use the printf utility derived from the
174       Ninth Edition system.
175
176       As specified, echo writes its arguments in the simplest of  ways.   The
177       two  different historical versions of echo vary in fatally incompatible
178       ways.
179
180       The BSD echo checks the first argument for the string -n  which  causes
181       it  to  suppress  the  <newline>  that would otherwise follow the final
182       argument in the output.
183
184       The System V echo does not  support  any  options,  but  allows  escape
185       sequences  within its operands, as described for XSI implementations in
186       the OPERANDS section.
187
188       The echo utility does not support Utility Syntax Guideline  10  because
189       historical  applications  depend  on echo to echo all of its arguments,
190       except for the -n option in the BSD version.
191

FUTURE DIRECTIONS

193       None.
194

SEE ALSO

196       printf
197
199       Portions of this text are reprinted and reproduced in  electronic  form
200       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
201       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
202       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
203       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
204       event of any discrepancy between this version and the original IEEE and
205       The Open Group Standard, the original IEEE and The Open Group  Standard
206       is  the  referee document. The original Standard can be obtained online
207       at http://www.opengroup.org/unix/online.html .
208
209
210
211IEEE/The Open Group                  2003                             ECHO(1P)
Impressum