Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Echo (command)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Shell command for writing to standard output}} {{otheruses|Echo (disambiguation)}} {{lowercase}} {{Infobox software | name = echo | logo = | screenshot = Sleepunix.png | screenshot size = | caption = The {{code|echo}} command on [[Unix]] | author = [[Douglas McIlroy]]<br />([[AT&T Bell Laboratories]]) | developer = Various [[open-source software|open-source]] and [[commercial software|commercial]] developers | released = | latest release version = | latest release date = | operating system = [[Multics]], [[Unix]], [[Unix-like]], [[V (operating system)|V]], [[Plan 9 from Bell Labs|Plan 9]], [[Inferno (operating system)|Inferno]], [[FLEX (operating system)|FLEX]], [[TRIPOS]], [[AmigaDOS]], [[Z80-RIO]], [[OS-9]], [[DOS]], [[MSX-DOS]], [[Panos (operating system)|Panos]], [[FlexOS]], [[SISNE plus]], [[OS/2]], [[Microsoft Windows|Windows]], [[ReactOS]], [[HP Multi-Programming Executive|MPE/iX]], [[KolibriOS]], [[SymbOS]] | platform = [[Cross-platform]] | genre = [[Command (computing)|Command]] | license = | website = }} '''<code>echo</code>''' is [[shell (computing)|shell]] [[command (computing)|command]] that writes input text to [[standard output]]. It is available in many [[operating system]] and [[shell (computing)|shells]]. It is often used in a [[shell script]] to [[Logging (computing)|log]] status, provide feedback to the user and for [[debugging]]. For an interactive session, output by default displays on the [[computer terminal|terminal]] screen, but output can be [[Redirection (computing)|re-directed]] to a [[computer file|file]] or [[Pipeline (Unix)|piped]] to another process.<ref name="rugheimer-spanik-amigados" /> Many shells implement <code>echo</code> as a [[shell builtin|builtin command]] rather than an external [[application software|application]] as are many other commands. Multiple, incompatible implementations of <code>echo</code> exist in different shells. Some expand escape sequences by default; some do not; some accept options; some do not. The [[POSIX]] specification<ref>{{man|cu|echo|SUS|write arguments to standard output}}</ref> leaves the behavior unspecified if the first argument is <code>-n</code> or any argument contains backslash characters while the Unix specification (XSI option in POSIX) mandates the expansion of some sequences and does not allow any option processing. In practice, many <code>echo</code> implementations are not compliant in the default environment. Because of these variations, <code>echo</code> is considered a non-portable command<ref name="echo limitations" /> and the [[printf (Unix)|<code>printf</code> command]] (introduced in Ninth Edition Unix) is preferred instead. ==Implementations== The command is available the following shells or at least one shell of a listed operating system: * [[Unix]] and [[Unix-like]] shells * [[Windows]]<ref name="windows-commands" /> * [[Multics]]<ref name="multics" /> * [[OS/2]]<ref name="jatomes" /> * [[DOS]] * [[Technical Systems Consultants|TSC]] [[FLEX (operating system)|FLEX]]<ref name="flexusergroup" /> * [[MetaComCo]] [[TRIPOS]]<ref name="tripos" /> * [[Zilog]] [[Z80-RIO]]<ref name="z80 user guide" /> * [[OS-9]]<ref name="os-9 guru" /> * [[Panos (operating system)|Panos]]<ref name="computinghistory" /> * [[FlexOS]]<ref name="flexos user guide" /> * [[ReactOS]]<ref name="reactos" /> * [[HP Multi-Programming Executive|MPE/iX]]<ref name="teamnaconsulting" /> * [[KolibriOS]]<ref name="kolibrios" /> * [[SymbOS]] * [[Unified Extensible Firmware Interface|EFI shell]].<ref name="EFI-Shells-and-Scripting" /> ==History== <code>echo</code> began within [[Multics]]. After it was programmed in [[C (programming language)|C]] by [[Douglas McIlroy|Doug McIlroy]] as a "finger exercise" and proved to be useful, it became part of [[Version 2 Unix]]. <code>echo -n</code> in [[Version 7 Unix|Version 7]] replaced <code>prompt</code>, (which behaved like <code>echo</code> but without terminating its output with a line delimiter).<ref name="reader" /> On [[PWB/UNIX]] and later [[Unix System III]], <code>echo</code> started expanding [[Escape sequences in C|C escape sequences]] such as <code>\n</code> with the notable difference that octal escape sequences were expressed as <code>\0ooo</code> instead of <code>\ooo</code> in C.<ref name="mascheck-echo" /> [[Research Unix|Eighth Edition Unix]] <code>echo</code> only did the escape expansion when passed a <code>-e</code> option,<ref name="man echo" /> and that behaviour was copied by a few other implementations such as the builtin <code>echo</code> command of [[Bash (Unix shell)|Bash]] or [[zsh]] and GNU <code>echo</code>. On [[MS-DOS]], the command is available in versions 2 and later.<ref name="RUNNINGMSDOS" /> ==Examples== <syntaxhighlight lang="doscon"> C:\>echo Hello world Hello world </syntaxhighlight> Using [[ANSI escape code]] ''SGR'' sequences, compatible terminals can print out colored text. Using a [[UNIX System III]]-style implementation: <syntaxhighlight lang="bash"> BGRED=`echo "\033[41m"` FGBLUE=`echo "\033[35m"` BGGREEN=`echo "\033[42m"` NORMAL=`echo "\033[m"` </syntaxhighlight> Or a Unix Version 8-style implementation (such as Bash when not in Unix-conformance mode): <syntaxhighlight lang="bash"> BGRED=`echo -e "\033[41m"` FGBLUE=`echo -e "\033[35m"` BGGREEN=`echo -e "\033[42m"` NORMAL=`echo -e "\033[m"` </syntaxhighlight> and after: <syntaxhighlight lang="bash"> echo "${FGBLUE} Text in blue ${NORMAL}" echo "Text normal" echo "${BGRED} Background in red" echo "${BGGREEN} Background in Green and back to Normal ${NORMAL}" </syntaxhighlight> Portably with <code>printf</code>: <syntaxhighlight lang="bash"> BGRED=`printf '\33[41m'` NORMAL=`printf '\33[m'` printf '%s\n' "${BGRED}Text on red background${NORMAL}" </syntaxhighlight> ==See also== * {{Annotated link|List of DOS commands}} * {{Annotated link|List of POSIX commands}} ==References== {{Reflist|refs= <ref name="EFI-Shells-and-Scripting">{{cite web | url = http://software.intel.com/en-us/articles/efi-shells-and-scripting/ | title = EFI Shells and Scripting | publisher = [[Intel]] | access-date = 2013-09-25 }}</ref> <ref name="mascheck-echo">{{cite web|last1=Mascheck|first1=Sven|title=echo and printf behaviour|url=http://www.in-ulm.de/~mascheck/various/echo+printf/|access-date=24 July 2016}}</ref> <ref name="man echo">{{cite web|title=8th Edition Unix echo man page|url=http://man.cat-v.org/unix_8th/1/echo|access-date=24 July 2016}}</ref> <ref name="echo limitations">{{cite web|title=Autoconf documentation on echo portability|url=https://www.gnu.org/software/autoconf/manual/autoconf-2.66/html_node/Limitations-of-Builtins.html#echo|publisher=Free Software Foundation|access-date=24 July 2016}}</ref> <ref name="RUNNINGMSDOS">{{Cite book|author-last=Wolverton|author-first=Van|title=Running MS-DOS Version 6.22 (20th Anniversary Edition), 6th Revised edition|date=2003|publisher=[[Microsoft Press]]|isbn=0-7356-1812-7}}</ref> <ref name="jatomes">{{Cite web |url=http://www.jatomes.com/Help/Os2Bat.php |title=OS/2 Batch File Commands |archive-url=https://web.archive.org/web/20190414130026/http://www.jatomes.com/Help/Os2Bat.php |archive-date=2019-04-14 |url-status=dead}}</ref> <ref name="flexos user guide">{{Cite web |url=http://www.bitsavers.org/pdf/digitalResearch/flexos/1073-2003_FlexOS_Users_Guide_V1.3_Nov86.pdf |title=FlexOS™ User's Guide |archive-url=https://web.archive.org/web/20180914132130/http://www.bitsavers.org/pdf/digitalResearch/flexos/1073-2003_FlexOS_Users_Guide_V1.3_Nov86.pdf |archive-date=2018-09-14 |url-status=dead}}</ref> <ref name="tripos">{{cite web |url=https://www.pagetable.com/docs/amigados_tripos/tripos_manuals.pdf |title= Manual |website=www.pagetable.com|access-date=2020-09-12}}</ref> <ref name="z80 user guide">{{Cite web |url=https://www.z80cpu.eu/mirrors/oldcomputers.dyndns.org/public/pub/rechner/zilog/zds/z80-rio_os_userman.pdf |title=Z80-RIO OPERATING SYSTEM USER'S MANUAL}}</ref> <ref name="os-9 guru">{{cite book|author=Paul S. Dayan|year=1992|title=The OS-9 Guru - 1 : The Facts|publisher=Galactic Industrial Limited|isbn=0-9519228-0-7}}</ref> <ref name="reader">{{cite tech report |first1=M. D. |last1=McIlroy |author-link1=Doug McIlroy |year=1987 |url=http://www.cs.dartmouth.edu/~doug/reader.pdf |title=A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 |series=CSTR |number=139 |institution=Bell Labs}}</ref> <ref name="rugheimer-spanik-amigados">{{Cite book|url=https://archive.org/details/1988-rugheimer-spanik-amigados-quick-reference|title=AmigaDOS quick reference|first1=Hannes|last1=Rügheimer|first2=Christian|last2=Spanik|date=September 12, 1988|publisher=Grand Rapids, Mi : Abacus|isbn=9781557550491|via=Internet Archive}}</ref> <ref name="computinghistory">{{Cite web|url=http://chrisacorns.computinghistory.org.uk/Panos.html#CL|title=Chris's Acorns: Panos|website=chrisacorns.computinghistory.org.uk}}</ref> <ref name="windows-commands">{{Cite web|url=https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/echo|title=echo|website=docs.microsoft.com|date=2 October 2023 }}</ref> <ref name="flexusergroup">{{Cite web|url=http://www.flexusergroup.com/flexusergroup/pdfs/swflexum.pdf|title=FLEX 9.0 User's Manual}}</ref> <ref name="teamnaconsulting">{{Cite web |url=http://www.teamnaconsulting.com/compresources/pdfs/c01687363.pdf |title=MPE/iX Command Reference Manual |access-date=2018-10-21 |archive-date=2018-10-21 |archive-url=https://web.archive.org/web/20181021232213/http://www.teamnaconsulting.com/compresources/pdfs/c01687363.pdf |url-status=dead }}</ref> <ref name="reactos">{{Cite web|url=https://github.com/reactos/reactos|title=reactos/reactos|website=GitHub|date=3 January 2022}}</ref> <ref name="kolibrios">{{Cite web|url=http://wiki.kolibrios.org/wiki/Shell|title=Shell - KolibriOS wiki|website=wiki.kolibrios.org}}</ref> <ref name="multics">{{Cite web|url=https://www.multicians.org/multics-commands.html|title=Multics Commands|website=www.multicians.org}}</ref> }} ==Further reading== *{{Cite book|author-last=Wolverton|author-first=Van|title=MS-DOS Commands: Microsoft Quick Reference, 4th Revised edition|date=1990|publisher=[[Microsoft Press]]|isbn=978-1556152894}} *{{Cite book|author1=Kathy Ivens|author2=Brian Proffit|year=1993|title=OS/2 Inside & Out|publisher=[[Osborne McGraw-Hill]]|isbn=978-0078818714}} *{{Cite book|first=Æleen|last=Frisch|year=2001|title=Windows 2000 Commands Pocket Reference|publisher=[[O'Reilly Media|O'Reilly]]|isbn=978-0-596-00148-3}} ==External links== {{Wikibooks|Guide to Windows Commands}} {{Wikibooks|Guide to Unix|Commands}} *{{man|cu|echo|SUS|write arguments to standard output}} *{{man|1|echo|Plan 9}} *{{man|1|echo|Inferno}} *[https://technet.microsoft.com/en-us/library/bb490897.aspx Microsoft TechNet Echo article] {{Unix commands}} {{Plan 9 commands}} {{Core Utilities commands}} {{Windows commands}} [[Category:Internal DOS commands]] [[Category:MSX-DOS commands]] [[Category:OS/2 commands]] [[Category:ReactOS commands]] [[Category:Windows commands]] [[Category:Multics commands]] [[Category:Standard Unix programs]] [[Category:Unix SUS2008 utilities]] [[Category:Plan 9 commands]] [[Category:Inferno (operating system) commands]] [[Category:IBM i Qshell commands]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Annotated link
(
edit
)
Template:Cite book
(
edit
)
Template:Core Utilities commands
(
edit
)
Template:Infobox software
(
edit
)
Template:Lowercase
(
edit
)
Template:Man
(
edit
)
Template:Otheruses
(
edit
)
Template:Plan 9 commands
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Unix commands
(
edit
)
Template:Wikibooks
(
edit
)
Template:Windows commands
(
edit
)