ECHO(1P)
π ECHO(1P) β the POSIX Programmer's Manual glow-up π
okay bestie so this is ECHO(1P), straight out of the POSIX Programmer's Manual β¨ and she's an icon, she's a legend, and she's literally the first command everyone ever learns. no cap.
π«Ά heads up though: this page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so pls consult the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface might not even be implemented on Linux at all. π
πΈ PROLOG πΈ
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β consult the corresponding Linux manual page for details of Linux behavior β or the interface may not be implemented on Linux. that's it that's the prolog, mwah π
β¨ NAME β¨
echo β write arguments to standard output. she says what you tell her to say, periodt.
π SYNOPSIS π
echo [string...]
π¦ DESCRIPTION π¦
The echo utility writes its arguments to standard output, followed by a <newline>. and if there are no arguments?? then only the <newline> gets written. she's lowkey minimal like that. β¨
π OPTIONS π
okay so this is the part where I have to tell you something kind of unhinged: the echo utility shall not recognize the "--" argument in the manner specified by Guideline 10 of the Base Definitions volume of POSIX.1β2017, Section 12.2, Utility Syntax Guidelines. nope. instead, "--" shall be recognized as a string operand. she does not care about your fancy end-of-options marker bestie π
and the wildest part: implementations shall not support any options. zero. none. not a single one. it's giving "I'm booked and busy and I don't do flags." π
π OPERANDS π
The following operands shall be supported:
- string β a string to be written to standard output. but here's the tea π«: if the first operand is
-n, or if any of the operands contain a<backslash>character, the results are implementation-defined. so like, good luck, it's vibes-based territory.
On XSI-conformant systems, if the first operand is -n, it shall be treated as a string, not an option. and on XSI-conformant systems, the following character sequences shall be recognized within any of the arguments:
\aβ write an<alert>.\bβ write a<backspace>.\cβ suppress the<newline>that otherwise follows the final argument in the output. and literally all characters following the'\c'in the arguments shall be ignored. she said "we're done here" π\fβ write a<form-feed>.\nβ write a<newline>.\rβ write a<carriage-return>.\tβ write a<tab>.\vβ write a<vertical-tab>.\\β write a<backslash>character.\0numβ write an 8-bit value that is the zero, one, two, or three-digit octal number num.
π STDIN π
Not used. she doesn't read, she only speaks. main character energy fr fr π
β INPUT FILES β
None.
π ENVIRONMENT VARIABLES π
The following environment variables shall affect the execution of echo:
LANGβ provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1β2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)LC_ALLβ if set to a non-empty string value, override the values of all the other internationalization variables. she overrides. that's her thing. πLC_CTYPEβ determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte 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 catalogs for the processing ofLC_MESSAGES.
π§ ASYNCHRONOUS EVENTS π§
Default. she's chill like that π¦
πΈ STDOUT πΈ
The echo utility arguments shall be separated by single <space> characters and a <newline> character shall follow the last argument. output transformations shall occur based on the escape sequences in the input. see the OPERANDS section for that whole situation, bestie π
π STDERR π
The standard error shall be used only for diagnostic messages. no drama unless something's actually wrong π
β¨ OUTPUT FILES β¨
None.
π¦ EXTENDED DESCRIPTION π¦
None. nothing extra. she's simple. she's iconic. she's echo. π«Ά
π EXIT STATUS π
The following exit values shall be returned:
0β successful completion. slay.>0β an error occurred. π
π CONSEQUENCES OF ERRORS π
Default.
The following sections are informative. (yes bestie, we're in the bonus content now, keep scrolling β¬οΈ)
π APPLICATION USAGE π
ngl this is the important part. it is not possible to use echo portably across all POSIX systems unless both -n (as the first argument) and escape sequences are omitted. so likeβ¦ just don't touch either one and you're fine?? mostly?? π
The printf utility can be used portably to emulate any of the traditional behaviors of the echo utility as follows (assuming that IFS has its standard value or is unset):
- The historic System V
echoand the requirements on XSI implementations in this volume of POSIX.1β2017 are equivalent to:
printf "%b\n$*"
- The BSD
echois 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. I know, I know, heartbreaking. she's still iconic though π
π EXAMPLES π
None. (crying, shaking, throwing up β I wanted examples π)
β RATIONALE β
The echo utility has not been made obsolescent because of its extremely widespread use in historical applications. Conforming applications that wish to do prompting without <newline> characters or that could possibly be expecting to echo a -n, should use the printf utility derived from the Ninth Edition system.
As specified, echo writes its arguments in the simplest of ways. The two different historical versions of echo vary in fatally incompatible ways. π like they are NOT friends.
The BSD echo checks the first argument for the string -n which causes it to suppress the <newline> that would otherwise follow the final argument in the output.
The System V echo does not support any options, but allows escape sequences within its operands, as described for XSI implementations in the OPERANDS section.
The echo utility does not support Utility Syntax Guideline 10 because historical applications depend on echo to echo all of its arguments, except for the -n option in the BSD version. she's grandfathered in, your honor π
π FUTURE DIRECTIONS π
None. she's not changing, bestie. she's perfect as she is. π¦
π§ SEE ALSO π§
printf
The Base Definitions volume of POSIX.1β2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page babes π«Ά this beauty is brought to you by IEEE/The Open Group, 2017 β yes, the year, the whole vibe, and the manpage name ECHO(1P). go forth and echo responsibly, bestie. mwah πβ¨π
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms