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 of LC_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 echo and the requirements on XSI implementations in this volume of POSIX.1‐2017 are 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. 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


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