echo
is
shell
Shell may refer to:
Architecture and design
* Shell (structure), a thin structure
** Concrete shell, a thin shell of concrete, usually with no interior columns or exterior buttresses
Science Biology
* Seashell, a hard outer layer of a marine ani ...
command
Command may refer to:
Computing
* Command (computing), a statement in a computer language
* command (Unix), a Unix command
* COMMAND.COM, the default operating system shell and command-line interpreter for DOS
* Command key, a modifier key on A ...
that writes input text to
standard output Standard may refer to:
Symbols
* Colours, standards and guidons, kinds of military signs
* Standard (emblem), a type of a large symbol or emblem used for identification
Norms, conventions or requirements
* Standard (metrology), an object t ...
. It is available in many
operating system
An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ...
and
shells. It is often used in a
shell script
A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be command languages. Typical operations performed by shell scripts include file manipu ...
to
log
Log most often refers to:
* Trunk (botany), the stem and main wooden axis of a tree, called logs when cut
** Logging, cutting down trees for logs
** Firewood, logs used for fuel
** Lumber or timber, converted from wood logs
* Logarithm, in mathe ...
status, provide feedback to the user and for
debugging
In engineering, debugging is the process of finding the Root cause analysis, root cause, workarounds, and possible fixes for bug (engineering), bugs.
For software, debugging tactics can involve interactive debugging, control flow analysis, Logf ...
. For an interactive session, output by default displays on the
terminal screen, but output can be
re-directed to a
file or
piped to another process.
Many shells implement
echo
as a
builtin command rather than an external
application as are many other commands.
Multiple, incompatible implementations of
echo
exist in different shells. Some expand escape sequences by default; some do not; some accept options; some do not. The
POSIX
The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
specification
leaves the behavior unspecified if the first argument is
-n
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
echo
implementations are not compliant in the default environment. Because of these variations,
echo
is considered a non-portable command
and the
printf
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
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
and
Unix-like
A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
shells
*
Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
*
Multics
Multics ("MULTiplexed Information and Computing Service") is an influential early time-sharing operating system based on the concept of a single-level memory.Dennis M. Ritchie, "The Evolution of the Unix Time-sharing System", Communications of t ...
*
OS/2
OS/2 is a Proprietary software, proprietary computer operating system for x86 and PowerPC based personal computers. It was created and initially developed jointly by IBM and Microsoft, under the leadership of IBM software designer Ed Iacobucci, ...
*
DOS
DOS (, ) is a family of disk-based operating systems for IBM PC compatible computers. The DOS family primarily consists of IBM PC DOS and a rebranded version, Microsoft's MS-DOS, both of which were introduced in 1981. Later compatible syste ...
*
TSC FLEX
*
MetaComCo
MetaComCo (MCC) was a computer systems software company started in 1981 and based in Bristol, England by Peter Mackeonis and Derek Budge. A division of Tenchstar, Ltd.
MetaComCo's first product was an MBASIC compatible interpreter for IBM PCs, ...
TRIPOS
TRIPOS (''TRIvial Portable Operating System'') is a computer operating system. Development started in 1976 at the Computer Laboratory of Cambridge University and it was headed by Dr. Martin Richards. The first version appeared in January 1978 a ...
*
Zilog
Zilog, Inc. is an American manufacturer of microprocessors, microcontrollers, and application-specific embedded System on a chip, system-on-chip (SoC) products.
The company was founded in 1974 by Federico Faggin and Ralph Ungermann, who were soo ...
Z80-RIO
*
OS-9
OS-9 is a family of real-time, process-based, multitasking, multi-user operating systems, developed in the 1980s, originally by Microware Systems Corporation for the Motorola 6809 microprocessor. It was purchased by Radisys Corp in 2001, a ...
*
Panos
*
FlexOS
FlexOS is a discontinued modular real-time multiuser multitasking operating system ( RTOS) designed for computer-integrated manufacturing, laboratory, retail and financial markets. Developed by Digital Research's Flexible Automation Business ...
*
ReactOS
ReactOS is a Free and open-source software, free and open-source operating system for i586/amd64 personal computers that is intended to be binary-code compatibility, binary-compatible with computer programs and device drivers developed for Wind ...
*
MPE/iX
*
KolibriOS
KolibriOS is an open-source operating system for x86 computers, written completely in FASM assembly language. It has been developed since 2004, forked from MenuetOS, and supports i586 CPU, CPUs or newer. KolibriOS is small sized and fits on a sin ...
*
SymbOS
SYmbiosis Multitasking Based Operating System (SymbOS) is a Computer multitasking, multitasking operating system for Zilog Z80-based 8-bit computer systems.
Unlike early 8-bit operating systems, SymbOS is based on a microkernel, which provides ...
*
EFI shell.
History
echo
began within
Multics
Multics ("MULTiplexed Information and Computing Service") is an influential early time-sharing operating system based on the concept of a single-level memory.Dennis M. Ritchie, "The Evolution of the Unix Time-sharing System", Communications of t ...
. After it was programmed in
C by
Doug McIlroy
Malcolm Douglas McIlroy (born 1932) is an American mathematician, engineer, and programmer. As of 2019 he is an Adjunct Professor of Computer Science at Dartmouth College.
McIlroy is best known for having originally proposed Unix pipelines and de ...
as a "finger exercise" and proved to be useful, it became part of
Version 2 Unix
Research Unix refers to the early versions of the Unix operating system for DEC PDP-7, PDP-11, VAX and Interdata 7/32 and 8/32 computers, developed in the Bell Labs Computing Sciences Research Center (CSRC). The term ''Research Unix'' first appe ...
.
echo -n
in
Version 7 replaced
prompt
, (which behaved like
echo
but without terminating its output with a line delimiter).
On
PWB/UNIX
The Programmer's Workbench (PWB/UNIX) was an early, now discontinued, version of the Unix operating system that had been created in the Bell Labs Computer Science Research Group of AT&T. Its stated goal was to provide a time-sharing working envi ...
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.
Eighth Edition Unix
Research Unix refers to the early versions of the Unix operating system for DEC PDP-7, PDP-11, VAX and Interdata 7/32 and 8/32 computers, developed in the Bell Labs Computing Sciences Research Center (CSRC). The term ''Research Unix'' first appea ...
echo
only did the escape expansion when passed a
-e
option,
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
MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few op ...
, the command is available in versions 2 and later.
Examples
C:\>echo Hello world
Hello world
Using
ANSI escape code
ANSI escape sequences are a standard for in-band signaling to control cursor location, color, font styling, and other options on video text terminals and terminal emulators. Certain sequences of bytes, most starting with an Escape character#ASC ...
''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 "$ Text in blue $"
echo "Text normal"
echo "$ Background in red"
echo "$ Background in Green and back to Normal $"
Portably with
printf
:
BGRED=`printf '\33[41m'`
NORMAL=`printf '\33[m'`
printf '%s\n' "$Text on red background$"
See also
*
*
References
Further reading
*
*
*
External links
*
*
*
Microsoft TechNet Echo article
{{Windows commands
Internal DOS commands
MSX-DOS commands
OS/2 commands
ReactOS commands
Windows commands
Multics commands
Standard Unix programs
Unix SUS2008 utilities
Plan 9 commands
Inferno (operating system) commands
IBM i Qshell commands