Echo (command)

Short description: Command of DOS, OS/2, Microsoft Windows, Unix and Unix-like operating systems

echo

The `echo` command on Unix

Original author(s)| Douglas McIlroy
(AT&T Bell Laboratories)
Developer(s)| Various open-source and commercial developers
Operating system| Multics, Unix, Unix-like, V, Plan 9, Inferno, FLEX, TRIPOS, AmigaDOS, Z80-RIO, OS-9, DOS, MSX-DOS, Panos, FlexOS, SISNE plus, OS/2, Windows, ReactOS, MPE/iX, KolibriOS, SymbOS
Platform| Cross-platform
Type| Command

In computing, `echo` is a command that outputs the strings that are passed to it as arguments. It is a command available in various operating system shells and typically used in shell scripts and batch files to output status text to the screen[1] or a computer file, or as a source part of a pipeline.

## Contents

* 1 Implementations
* 2 History
* 3 Usage examples
* 4 See also
* 5 References
* 6 Further reading
* 7 External links

## Implementations

The command is available in the following operating systems:

* Multics[2]
* TSC FLEX[3]
* MetaComCo TRIPOS[4]
* Zilog Z80-RIO[5]
* Microware OS-9[6]
* DOS
* Acorn Computers Panos[7]
* Digital Research FlexOS[8]
* IBM OS/2[9]
* Microsoft Windows[10]
* ReactOS[11]
* HP MPE/iX[12]
* KolibriOS[13]
* SymbOS
* Unix and Unix-like operating systems

Many shells, including all Bourne-like (such as Bash[14] or zsh[15]) and Csh-like shells as well as COMMAND.COM and cmd.exe implement `echo` as a builtin command.

The command is also available in the EFI shell.[16]

## History

`echo` began within Multics. After it was programmed in C by Doug McIlroy as a "finger exercise" and proved to be useful, it became part of Version 2 Unix. `echo -n` in Version 7 replaced `prompt`, (which behaved like `echo` but without terminating its output with a line delimiter).[17]

On PWB/UNIX and later Unix System III, `echo` started expanding C escape sequences such as `\n` with the notable difference that octal escape sequences were expressed as `\0ooo` instead of `\ooo` in C.[18]

Eighth Edition Unix `echo` only did the escape expansion when passed a `-e` option,[19] and that behaviour was copied by a few other implementations such as the builtin `echo` command of Bash or zsh and GNU `echo`.

On MS-DOS, the command is available in versions 2 and later.[20]

Nowadays, several incompatible implementations of `echo` exist on different operating systems (often several on the same system), some of them expanding escape sequences by default, some of them not, some of them accepting options (the list of which varying with implementations), some of them not.

The POSIX specification of `echo`[21] leaves the behaviour unspecified if the first argument is `-n` or any argument contain 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 `echo` implementations are not compliant in the default environment.

Because of these variations in behaviour, `echo` is considered a non-portable command on Unix-like systems[22] and the `printf` command (where available, introduced by Ninth Edition Unix) is preferred instead.

## Usage examples

C:\>echo Hello world
Hello world

Using ANSI escape code SGR sequences, compatible terminals can print out colored text.

Using a UNIX System III-style implementation:

BGRED=`echo "\033[41m"`
FGBLUE=`echo "\033[35m"`
BGGREEN=`echo "\033[42m"`

NORMAL=`echo "\033[m"`

Or a Unix Version 8-style implementation (such as Bash when not in Unix-conformance mode):

BGRED=`echo -e "\033[41m"`
FGBLUE=`echo -e "\033[35m"`
BGGREEN=`echo -e "\033[42m"`

NORMAL=`echo -e "\033[m"`

and after:

echo "${FGBLUE} Text in blue ${NORMAL}"
echo "Text normal"
echo "${BGRED} Background in red"
echo "${BGGREEN} Background in Green and back to Normal ${NORMAL}"

Portably with `printf`:

BGRED=`printf '\33[41m'`
NORMAL=`printf '\33[m'`
printf '%s\n' "${BGRED}Text on red background${NORMAL}"

## See also

* List of Unix commands
* List of DOS commands

## References

1. ↑ Rügheimer, Hannes; Spanik, Christian (September 12, 1988). AmigaDOS quick reference. Grand Rapids, Mi : Abacus. ISBN 9781557550491. https://archive.org/details/1988-rugheimer-spanik-amigados-quick-reference.
2. ↑ "Multics Commands". https://www.multicians.org/multics-commands.html.
3. ↑ "FLEX 9.0 User's Manual". http://www.flexusergroup.com/flexusergroup/pdfs/swflexum.pdf.
4. ↑ "Manual". https://www.pagetable.com/docs/amigados_tripos/tripos_manuals.pdf.
5. ↑ "Z80-RIO OPERATING SYSTEM USER'S MANUAL". https://www.z80cpu.eu/mirrors/oldcomputers.dyndns.org/public/pub/rechner/zilog/zds/z80-rio_os_userman.pdf.
6. ↑ Paul S. Dayan (1992). The OS-9 Guru - 1 : The Facts. Galactic Industrial Limited. ISBN 0-9519228-0-7.
7. ↑ "Chris's Acorns: Panos". http://chrisacorns.computinghistory.org.uk/Panos.html#CL.
8. ↑ "FlexOS™ User's Guide". http://www.bitsavers.org/pdf/digitalResearch/flexos/1073-2003_FlexOS_Users_Guide_V1.3_Nov86.pdf.
9. ↑ "OS/2 Batch File Commands". http://www.jatomes.com/Help/Os2Bat.php.
10. ↑ "echo". 2 October 2023. https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/echo.
11. ↑ "reactos/reactos". 3 January 2022. https://github.com/reactos/reactos.
12. ↑ "MPE/iX Command Reference Manual". http://www.teamnaconsulting.com/compresources/pdfs/c01687363.pdf.
13. ↑ "Shell - KolibriOS wiki". http://wiki.kolibrios.org/wiki/Shell.
14. ↑ "Bash Builtins (Bash Reference Manual)". https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html.
15. ↑ "zsh: 17 Shell Builtin Commands". http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html.
16. ↑ "EFI Shells and Scripting". Intel. http://software.intel.com/en-us/articles/efi-shells-and-scripting/.
17. ↑ McIlroy, M. D. (1987). A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 (PDF) (Technical report). CSTR. Bell Labs. 139.
18. ↑ Mascheck, Sven. "echo and printf behaviour". http://www.in-ulm.de/~mascheck/various/echo+printf/.
19. ↑ "8th Edition Unix echo man page". http://man.cat-v.org/unix_8th/1/echo.
20. ↑ Running MS-DOS Version 6.22 (20th Anniversary Edition), 6th Revised edition. Microsoft Press. 2003. ISBN 0-7356-1812-7.
21. ↑ `echo`: write arguments to standard output – Commands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
22. ↑ "Autoconf documentation on echo portability". Free Software Foundation. https://www.gnu.org/software/autoconf/manual/autoconf-2.66/html_node/Limitations-of-Builtins.html#echo.

## Further reading

* MS-DOS Commands: Microsoft Quick Reference, 4th Revised edition. Microsoft Press. 1990. ISBN 978-1556152894.
* Kathy Ivens; Brian Proffit (1993). OS/2 Inside & Out. Osborne McGraw-Hill. ISBN 978-0078818714.
* Frisch, Æleen (2001). Windows 2000 Commands Pocket Reference. O'Reilly. ISBN 978-0-596-00148-3.

## External links

* `echo`: write arguments to standard output – Commands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
* `echo(1)` – Plan 9 Programmer's Manual, Volume 1
* `echo(1)` – Inferno General commands Manual
* Microsoft TechNet Echo article

* v
* t
* e

Unix command-line interface programs and shell builtins

File system|

* cat
* chmod
* chown
* chgrp
* cksum
* cmp
* cp
* dd
* du
* df
* file
* fuser
* ln
* ls
* mkdir
* mv
* pax
* pwd
* rm
* rmdir
* split
* tee
* touch
* type
* umask

Processes|

* at
* bg
* crontab
* fg
* kill
* nice
* ps
* time

User environment|

* env
* exit
* logname
* mesg
* talk
* tput
* uname
* who
* write

Text processing|

* awk
* basename
* comm
* csplit
* cut
* diff
* dirname
* ed
* ex
* fold
* head
* iconv
* join
* m4
* more
* nl
* paste
* patch
* printf
* sed
* sort
* strings
* tail
* tr
* uniq
* vi
* wc
* xargs

Shell builtins|

* alias
* cd
* echo
* test
* unset
* wait

Searching|

* find
* grep

Documentation|

* man

Software development|

* ar
* ctags
* lex
* make
* nm
* strip
* yacc

Miscellaneous|

* bc
* cal
* expr
* lp
* od
* sleep
* true and false

* Categories
* Standard Unix programs
* Unix SUS2008 utilities
* List

* v
* t
* e

Windows command-line programs and shell builtins

* COMMAND.COM
* Command Prompt
* Windows PowerShell
* Recovery Console

File system navigation|

* cd (chdir)
* dir
* popd
* pushd
* tree

File management|

* attrib
* cacls
* cipher
* compact
* copy
* del (erase)
* deltree
* expand
* icacls
* makecab
* mkdir (md)
* mklink
* move
* recover
* ren (rename)
* replace
* rmdir (rd)
* robocopy
* tar
* xcopy

Disk management|

* chkdsk
* convert
* defrag
* diskcomp
* diskcopy
* diskpart
* drvspace
* fdisk
* format
* label
* manage-bde
* subst
* scandisk
* sys
* vol
* vssadmin

Processes|

* at
* exit
* kill
* powercfg
* runas
* sc
* schtasks
* shutdown
* start
* taskkill
* tasklist

Registry|

* assoc
* ftype
* reg
* regini
* regsvr32

User environment|

* date
* mode
* path
* set
* setx
* time
* title
* ver
* whoami

File contents|

* comp
* edit
* edlin
* fc
* find
* findstr
* print
* type

Scripting|

* choice
* clip
* cscript
* doskey
* echo
* for
* forfiles
* goto
* if
* more
* pause
* prompt
* rem
* timeout

Networking|

* arp
* BITSAdmin
* cURL
* getmac
* hostname
* ipconfig
* net
* netsh
* netstat
* nslookup
* PathPing
* ping
* route
* scp
* sftp
* ssh
* ssh-add
* ssh-agent
* ssh-keygen
* ssh-keyscan
* tracert
* winrm
* winrs

Maintenance and care|

* driverquery
* eventcreate
* eventtriggers
* msiexec
* ntbackup
* sfc
* systeminfo
* w32tm
* WBAdmin
* winsat
* wmic

Boot management|

* bcdedit
* bootcfg
* fixboot
* fixmbr

Software development|

* debug
* exe2bin
* QBasic

Miscellaneous|

* cls
* dism
* dpath
* gpupdate
* help
* MSCDEX
* pentnt
* wsl

* List of DOS commands
* Environment variables

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Echo (command). Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:Echo_(command)&oldid=753327"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template