Echo (command)

echo
Original author(s)Douglas McIlroy
(AT&T Bell Laboratories)
Developer(s)Various open-source and commercial developers
Operating systemMultics, 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
PlatformCross-platform
TypeCommand

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.

Implementations

The command is available in the following 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

References

  1. ^ Rügheimer, Hannes; Spanik, Christian (September 12, 1988). AmigaDOS quick reference. Grand Rapids, Mi : Abacus. ISBN 9781557550491 – via Internet Archive.
  2. ^ "Multics Commands". www.multicians.org.
  3. ^ "FLEX 9.0 User's Manual" (PDF).
  4. ^ "Manual" (PDF). www.pagetable.com. Retrieved 2020-09-12.
  5. ^ "Z80-RIO OPERATING SYSTEM USER'S MANUAL" (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". chrisacorns.computinghistory.org.uk.
  8. ^ "FlexOS™ User's Guide" (PDF). Archived from the original (PDF) on 2018-09-14.
  9. ^ "OS/2 Batch File Commands". Archived from the original on 2019-04-14.
  10. ^ "echo". docs.microsoft.com. 2 October 2023.
  11. ^ "reactos/reactos". GitHub. 3 January 2022.
  12. ^ "MPE/iX Command Reference Manual" (PDF). Archived from the original (PDF) on 2018-10-21. Retrieved 2018-10-21.
  13. ^ "Shell - KolibriOS wiki". wiki.kolibrios.org.
  14. ^ "Bash Builtins (Bash Reference Manual)". www.gnu.org.
  15. ^ "zsh: 17 Shell Builtin Commands". zsh.sourceforge.net.
  16. ^ "EFI Shells and Scripting". Intel. Retrieved 2013-09-25.
  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". Retrieved 24 July 2016.
  19. ^ "8th Edition Unix echo man page". Retrieved 24 July 2016.
  20. ^ Wolverton, Van (2003). Running MS-DOS Version 6.22 (20th Anniversary Edition), 6th Revised edition. Microsoft Press. ISBN 0-7356-1812-7.
  21. ^ echo: write arguments to standard output – Shell and Utilities Reference, The Single UNIX Specification, Version 4 from The Open Group
  22. ^ "Autoconf documentation on echo portability". Free Software Foundation. Retrieved 24 July 2016.

Further reading

Read other articles:

У этого термина существуют и другие значения, см. Политика Приднестровской Молдавской Республики. Приднестровская Молдавская Республика Эта статья является частьюсерии статей: Политика Приднестровской Молдавской Республики Конституция Президент Вадим Красносельски...

 

Este artigo não cita fontes confiáveis. Ajude a inserir referências. Conteúdo não verificável pode ser removido.—Encontre fontes: ABW  • CAPES  • Google (N • L • A) (Janeiro de 2014)  Nota: Para o código de leis do islamismo, veja Xaria. Charia Шарья País Rússia Oblast Kostroma População (2010) 38,8 mil habitantes Website http://adm-sharya.ru Cidade da Rússia O Commons possui uma categoria com imagens e outr...

 

سفارة دولة فلسطين لدى الصين فلسطين الصين الإحداثيات 39°56′10″N 116°27′17″E / 39.9362°N 116.4546°E / 39.9362; 116.4546  البلد الصين  المكان بكين العنوان منطقة سانليتون السَفير فريز مهداوي تعديل مصدري - تعديل   سفارة دولة فلسطين لدى الصين هي الممثلية الدبلوماسية العُليا لدولة...

Siegel von Albert II. Suerbeer Albert II. Suerbeer (* Ende des 12. Jahrhunderts in Köln; † zwischen November 1272 und März 1273 in Riga) war der erste Erzbischof von Riga. Leben Albert studierte an der Sorbonne, schloss mit dem Magistergrad ab und wurde Domscholaster in Bremen. Nach dem Tod von Albert von Buxthoeven 1229 wurde er vom Bremer Erzbischof Gerhard von Oldenburg zum Bischof von Riga ernannt. Das Domkapitel von Riga erkannte die Ernennung nicht an und wählte einen eigenen Kandi...

 

Don Antonio Pimentel de Prado (1604-1671/72)[1] Sébastien Bourdon, Christina van Zweden, 1653, Museo del Prado.[2] Antonio Pimentel de Prado y lo Bianco (Palermo, 1604 - Antwerpen (ca. 1671-72) was een Spaanse officier, een gouverneur van Nieuwpoort (1646-1651), ambassadeur in Stockholm (1652-1654), ridder in de Orde van Santiago (ant. a 1656)[3],[4] gevolmachtigde in Parijs (1659), gouverneur van Cadiz (1660-1670), raad en opperbevelhebber van het leger in An...

 

Sōja 総社市Kota BenderaLambangLokasi Sōja di Prefektur OkayamaNegara JepangWilayahChūgokuPrefektur OkayamaPemerintahan • Wali kotaSōichi KataokaLuas • Total212 km2 (82 sq mi)Populasi (Oktober 1, 2015) • Total66.855 • Kepadatan315,4/km2 (8,170/sq mi)Zona waktuUTC+9 (JST)Kode pos719-1192Simbol • PohonAcer• BungaAstragalus sinicus• BurungGrus japonensisNomor telepon0866-92-8200Alamat1-1-1 Chū

Marie-Anne, later the princesse des Ursins The Camarera mayor de Palacio (First Lady of the Bedchamber) was the Official of the Royal Household and Heritage of the Crown of Spain, who was in charge of the person and the rooms of the Queen of Spain. Historical precedents and regime during the 17th and 18th centuries This Office was created in 1526 when, during the Habsburg dynasty, the Royal Court was shaped after that one that existed in the Court of Burgundy. Charles V, Holy Roman Emperor, b...

 

Artikel ini perlu diterjemahkan dari bahasa Inggris ke bahasa Indonesia. Artikel ini ditulis atau diterjemahkan secara buruk dari Wikipedia bahasa Inggris. Jika halaman ini ditujukan untuk komunitas bahasa Inggris, halaman itu harus dikontribusikan ke Wikipedia bahasa Inggris. Lihat daftar bahasa Wikipedia. Artikel yang tidak diterjemahkan dapat dihapus secara cepat sesuai kriteria A2. Jika Anda ingin memeriksa artikel ini, Anda boleh menggunakan mesin penerjemah. Namun ingat, mohon tidak men...

 

Australian rules footballer Australian rules footballer Bill HoskingPersonal informationFull name Bill HoskingDate of birth (1940-07-19)19 July 1940Original team(s) Ballarat, Lismore (Vic)Height 178 cm (5 ft 10 in)Weight 74 kg (163 lb)Playing career1Years Club Games (Goals)1962 Geelong 5 (2) 1 Playing statistics correct to the end of 1962. Sources: AFL Tables, AustralianFootball.com Bill Hosking (born 19 July 1940) is a former Australian rules footballer who play...

المعهد الوطني للتقنيات الفضائية المعهد الوطني للتقنيات الفضائية تفاصيل الوكالة الحكومية البلد إسبانيا  تأسست 1942  المركز توريخون دي أردوز،  وموغير  الإحداثيات 40°29′32″N 3°28′37″W / 40.492222222222°N 3.4770833333333°W / 40.492222222222; -3.4770833333333  الموظفون 1493 (2020)،  و1200 (2008...

 

Современные антифашисты в России представлены как автономными аффинити-группами (члены которых могут иметь разные политические взгляды, начиная от левых социал-демократов и заканчивая ультралевыми марксистами и анархистами), так и общественными движениями и организа...

 

For other places with the same name, see Rattlesnake Island (disambiguation). Location of Rattlesnake Islands in the Bass Islands. Rattlesnake Island is an 85-acre (34 ha) island located on Lake Erie near Put-In-Bay, 11 miles (18 km) northeast of Port Clinton, Ohio. It is part of Put-in-Bay Township, in Ottawa County. It is one of several islands known as the Lake Erie Islands. The name Rattlesnake comes from the actual rattlesnakes that formerly inhabited the island, ( and supposed...

كان للرياضة أثرٌ على العلاقات بين الدول العربية بشكلٍ إيجابي في مُعظم الأوقات، وسلبيًا في حالاتٍٍ قليلة مثل مباراة مصر والجزائر الشهيرة في أم درمان عام 2009. تشجيع العرب للجزائر في كأس الأمم الإفريقية 2019 شهدت كأس الأمم الأفريقية 2019 منعطفات ايجابية مهمة على صعيد العلاقات الع...

 

Kenyan museumKisumu MuseumLuo's ber gi dala. The cow paddock. Kisumu Museum - KenyaEstablished1980LocationKisumu, KenyaCollectionslocal flora and fauna, as well as a traditional Luo homestead The Kisumu Museum is a museum located in Kisumu, Kenya.[1] Its exhibits focus on the natural and cultural history of Western Kenya. It features a collection of local flora and fauna, as well as a traditional Luo homestead. The museum was opened 1980. References ^ Kisumu - Location and Historical ...

 

Academic journalEx AudituDisciplineTheologyLanguageEnglishEdited byStephen J. ChesterPublication detailsHistory1985-presentPublisherWipf and StockStandard abbreviationsISO 4 (alt) · Bluebook (alt1 · alt2)NLM (alt) · MathSciNet (alt )ISO 4Ex AudituIndexingCODEN (alt · alt2) · JSTOR (alt) · LCCN (alt)MIAR · NLM (alt) · ScopusISSN0883-0053OCLC no.12032714Links Journal homepag...

このページのノートに、このページに関する問題提起があります。(2022年1月)問題提起の要約:記事の構成についてこの記事は特に記述がない限り、日本国内の法令について解説しています。また最新の法令改正を反映していない場合があります。ご自身が現実に遭遇した事件については法律関連の専門家にご相談ください。免責事項もお読みください。 衆議院小選...

 

Village in Kolubara District, SerbiaSovljak СовљакVillage (Selo)SovljakCoordinates: 44°27′N 20°02′E / 44.450°N 20.033°E / 44.450; 20.033Country SerbiaDistrictKolubara DistrictMunicipalityUbArea • Total17.61 km2 (6.80 sq mi)Elevation104 m (341 ft)Population (2011) • Total1,839 • Density100/km2 (270/sq mi)Time zoneUTC+1 (CET) • Summer (DST)UTC+2 (CEST)Old private granary...

 

Oststeirisches Hügelland Oststeirisches Hügelland, südlich von Herberstein Oststeirisches Hügelland, südlich von Herberstein Höchster Gipfel Stradner Kogel (609 m ü. A.) Lage Steiermark Teil von Alpenvorland im Osten und Südosten Einteilung nach L.d.St. V.4 Oststeirisches Hügelland (Pannonische Tiefebene) Koordinaten 47° 4′ N, 15° 48′ O47.06666666666715.808333333333609Koordinaten: 47° 4′ N, 15° 48′ O p1 Das Ostst...

Artikel ini membutuhkan rujukan tambahan agar kualitasnya dapat dipastikan. Mohon bantu kami mengembangkan artikel ini dengan cara menambahkan rujukan ke sumber tepercaya. Pernyataan tak bersumber bisa saja dipertentangkan dan dihapus.Cari sumber: Ricky Martin – berita · surat kabar · buku · cendekiawan · JSTOR Ricky MartinNama lahirEnrique Martín MoralesNama lainRicky MartinLahir24 Desember 1971 (umur 51)AsalSan Juan, Puerto RicoGenrePop, Latin ...

 

Offerta musicaleMusicalisches OpferLa prima pagina manoscritta del Ricercar à 6.CompositoreJohann Sebastian Bach TonalitàDo minore Tipo di composizioneRaccolta di fughe, canoni e una sonata Numero d'operaBWV 1079 Epoca di composizione1747 Pubblicazione1747 (1ª edizione, originale) 1885 (BGA XXXI.2) 1974 (NBA VIII/1) AutografoMusikalisches Opfer BWV 1079 Manuale Con Offerta musicale (nell'originale in tedesco, Musicalisches Opfer)[1] BWV 1079 ci si riferisce a una raccolta di Johann...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!