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
Ed (software)
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|Line-oriented text editor for Unix}} {{lowercase|title=ed (text editor)}} {{Infobox software | name = ed | screenshot = Ed lines.jpg | screenshot size = | caption = The {{code|ed}} text editor | author = [[Ken Thompson]] | developer = [[AT&T Bell Laboratories]] | released = {{Release year|df=yes|1973}} | programming language = [[C (programming language)|C]] | operating system = [[Unix]], [[Unix-like]], [[Plan 9 from Bell Labs|Plan 9]] | platform = [[Cross-platform]] | genre = [[Text editor]] | license = Plan 9: [[MIT License]] }} '''{{tt|ed}}''' (pronounced as distinct letters, {{IPAc-en|ˌ|iː|ˈ|d|iː}})<ref>{{Citation|last=Computerphile|title=Where GREP Came From – Computerphile|date=2018-07-06|url=https://www.youtube.com/watch?v=NTfOnGZUZDk&t=119| archive-url=https://ghostarchive.org/varchive/youtube/20211211/NTfOnGZUZDk| archive-date=2021-12-11 | url-status=live|access-date=2020-10-21}}{{cbignore}}</ref> is a [[line editor]] for [[Unix]] and [[Unix-like]] operating systems. It was one of the first parts of the Unix operating system that was developed, in August 1969.<ref name="penguin">{{cite book |first=Peter H. |last=Salus |author-link=Peter H. Salus |title=The Daemon, the Gnu and the Penguin |url=http://www.groklaw.net/article.php?story=20050414215646742 |publisher=[[Groklaw]] |year=2005|archive-url=https://web.archive.org/web/20100505073306/http://www.groklaw.net/article.php?story=20050414215646742 |archive-date=2010-05-05 }}</ref> It remains part of the [[POSIX]] and [[The Open Group|Open Group]] standards for Unix-based operating systems,<ref name=sus>{{man|cu|ed|SUS}}</ref> alongside the more sophisticated full-screen editor [[Vi (text editor)|vi]]. == History and influence == The ed text editor was one of the first three key elements of the Unix operating system—[[Assembly language#Assembler|assembler]], [[Line editor|editor]], and [[Unix shell|shell]]—developed by [[Ken Thompson]] in August 1969 on a [[PDP-7]] at [[AT&T Bell Labs]].<ref name="penguin"/> Many features of ed came from the [[QED (text editor)|qed]] text editor developed at Thompson's [[alma mater]] [[University of California, Berkeley]].<ref>D. M. Ritchie and K. L. Thompson, "QED Text Editor", [https://wayback.archive-it.org/all/20150203071645/http://cm.bell-labs.com/cm/cs/who/dmr/qedman.pdf MM-70-1373-3] (June 1970), reprinted as "QED Text Editor Reference Manual", MHCC-004, Murray Hill Computing, Bell Laboratories (October 1972).</ref> Thompson was very familiar with qed, and had reimplemented it on the [[Compatible Time-Sharing System|CTSS]] and [[Multics]] systems. Thompson's versions of qed were notable as the first to implement [[regular expression]]s. Regular expressions are also implemented in ed, though their implementation is considerably less general than that in qed. [[Dennis M. Ritchie]] produced what [[Doug McIlroy]] later described as the "definitive" ed,<ref name="reader">{{cite tech report |first1=M. D. |last1=McIlroy |author-link1=Doug McIlroy |year=1987 |url=https://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> and aspects of ed went on to influence [[Ex (text editor)|ex]], which in turn spawned [[Vi (text editor)|vi]]. The non-interactive Unix command [[grep]] was inspired by a common special use of qed and later ed, where the command <code>g/re/p</code> performs a '''g'''lobal '''r'''egular '''e'''xpression search and '''p'''rints the lines containing matches. The Unix stream editor, [[sed]] implemented many of the scripting features of [[QED (text editor)|qed]] that were not supported by ed on Unix.<ref>{{Cite web |last=Raymond |first=Eric |date=2003 |title=The Art of Unix Programming |url=https://nakamotoinstitute.org/static/docs/taoup.pdf |url-status=live |archive-url=https://web.archive.org/web/20230615012711/https://nakamotoinstitute.org/static/docs/taoup.pdf |archive-date=June 15, 2023 |access-date=June 14, 2023}}</ref>{{failed verification|date=June 2023}}<ref name=early_history> {{cite web | title = On the Early History and Impact of Unix | url = http://www.columbia.edu/~rh120/ch001j.c11 | quote = "A while later a demand arose for another special-purpose program, gres, for substitution: g/re/s. Lee McMahon undertook to write it, and soon foresaw that there would be no end to the family: g/re/d, g/re/a, etc. As his concept developed it became sed…" }} </ref> == Features == Features of ed include: * available on essentially all Unix systems (and mandatory on systems conforming to the [[Single Unix Specification]]). * support for [[regular expression]]s * powerful automation can be achieved by feeding commands from [[standard streams|standard input]] Known for its terseness, ed, compatible with [[teletype]] terminals like [[Teletype Model 33]], gives almost no visual feedback,<ref name="norman" /> and has been called (by [[Peter H. Salus]]) "the most user-hostile editor ever created", even when compared to the contemporary (and notoriously complex) [[TECO (text editor)|TECO]].{{r|penguin}} For example, the message that ed will produce in case of error, ''and'' when it wants to make sure the user wishes to quit without saving, is "?". It does not report the current filename or line number, or even display the results of a change to the text, unless requested. Older versions (c. 1981) did not even ask for confirmation when a quit command was issued without the user saving changes.<ref name="norman">{{cite journal |title=The truth about UNIX |author=Donald A. Norman |year=1981 |journal=[[Datamation]] |url=http://www.ceri.memphis.edu/people/smalley/ESCI7205_misc_files/The_truth_about_Unix_cleaned.pdf|archive-url=https://web.archive.org/web/20140416205707/http://www.ceri.memphis.edu/people/smalley/ESCI7205_misc_files/The_truth_about_Unix_cleaned.pdf |archive-date=2014-04-16 }}</ref> This terseness was appropriate in the early versions of Unix, when consoles were [[teleprinter|teletypes]], [[modem]]s were slow, and [[Random access memory|memory]] was precious. As computer technology improved and these constraints were loosened, editors with more visual feedback became the norm. [[File:Ed first lines of man page.png|thumb|The [[man page]] for ed]] In current practice, ed is rarely used interactively, but does find use in some [[shell script]]s. For interactive use, ed was subsumed by the [[sam (text editor)|sam]], [[Vi (text editor)|vi]] and [[Emacs]] editors in the 1980s. ed can be found on virtually every version of Unix and [[Linux]] available, and as such is useful for people who have to work with multiple versions of Unix. On Unix-based operating systems, some utilities like [[SQL*Plus]] run ed as the editor if the EDITOR and VISUAL environment variables are not defined.<ref>[https://docs.oracle.com/cd/E11882_01/server.112/e10839/admn_sqlpls.htm#UNXAR166 Administering SQL*Plus]. Accessed 7/23/2016.</ref> If something goes wrong, ed is sometimes the only editor available. This is often the only time when it is used interactively. The version of ed provided by [[GNU]] has a few switches to enhance the feedback. Using {{PreCode|ed -v -p:}} provides a simple prompt and enables more useful feedback messages.<ref>{{man|1|ed|ManKier}}</ref> The {{PreCode|-p}} switch is defined in POSIX since [[X/Open|XPG2]] (1987).<ref name=sus/> The ed commands are often imitated in other line-based editors. For example, [[edlin|EDLIN]] in early [[MS-DOS]] versions and [[32-bit]] versions of [[Windows NT]] has a somewhat similar syntax, and text editors in many [[Multi-user dungeon|MUD]]s ([[LPMud]] and descendants, for example) use ed-like syntax. These editors, however, are typically more limited in function. == Example == Here is an example transcript of an ed session. For clarity, commands and text typed by the user are in normal [[Typeface|face]], and output from ed is '''emphasized'''. a {{as written|ed is the standard Unix text editor.}} This is line number two. . 2i<br> . ,l '''ed is the standard Unix text editor.$''' '''$''' '''This is line number two.$''' w text.txt '''63''' {{codett|2=sed|3s/two/three/}} ,l '''ed is the standard Unix text editor.$''' '''$''' '''This is line number three.$''' w text.txt '''65''' q The end result is a simple text file <code>text.txt</code> containing the following text: ed is the standard Unix text editor.<br> This is line number three. Started with an empty file, the <code>a</code> command appends text (all ed commands are single letters). The command puts ed in ''insert mode'', inserting the characters that follow and is terminated by a single dot on a line. The two lines that are entered before the dot end up in the file buffer. The <code>2i</code> command also goes into insert mode, and will insert the entered text (a single empty line in our case) before line two. All commands may be prefixed by a line number to operate on that line. In the line <code>,l</code>, the lowercase L stands for the list command. The command is prefixed by a range, in this case <code>,</code> which is a shortcut for <code>1,$</code>. A range is two line numbers separated by a comma (<code>$</code> means the last line). In return, ed lists all lines, from first to last. These lines are ended with dollar signs, so that white space at the end of lines is clearly visible. Once the empty line is inserted in line 2, the line which reads "This is line number two." is now actually the third line. This error is corrected with {{code|2=sed|3s/two/three/}}, a substitution command. The <code>3</code> will apply it to the correct line; following the command is the text to be replaced, and then the replacement. Listing all lines with <code>,l</code> the line is shown now to be correct. <code>w text.txt</code> writes the buffer to the file <code>text.txt</code> making ed respond with ''65'', the number of characters written to the file. <code>q</code> will end an ed session. == Cultural references == The [[GNU]] Project has numerous jokes around ed hosted on its website. In addition, the [[glibc]] documentation notes an [[errno|error code]] called {{code|ED}} with its description (errorstr) merely a single question mark, noting "the experienced user will know what is wrong."<ref>{{cite web |title=The GNU C Library - Error Codes |url=https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html |website=www.gnu.org}}</ref> == See also == * [[Edlin]], the standard MS-DOS line editor which was inspired by ''ed'' * [[Sam (text editor)]] * [[Editor war]] * [[List of Unix commands]] == References == {{Reflist|30em}} == External links == {{Wikibooks|Guide to Unix|Commands}} * {{man|cu|ed|SUS|edit text}} * [http://man.cat-v.org/unix-1st/1/ed Manual page from Unix First Edition describing ed]. * {{man|1|ed|v7|text editor}} * {{man|1|ed|Plan 9|text editor}}, a direct descendant of the original ed. * [https://www.gnu.org/software/ed/ed.html GNU ed homepage] * [http://www.darwinsys.com/history/hist.html A History of UNIX before Berkeley] section 3.1 describes the history of ed. {{Unix commands}} {{Plan 9 commands}} {{Ken Thompson navbox}} [[Category:Unix text editors]] [[Category:MacOS text editors]] [[Category:Standard Unix programs]] [[Category:Unix SUS2008 utilities]] [[Category:Plan 9 commands]] [[Category:Line editor]] [[Category:1971 software]] [[Category:Console applications]]
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:As written
(
edit
)
Template:Cbignore
(
edit
)
Template:Citation
(
edit
)
Template:Cite book
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite tech report
(
edit
)
Template:Cite web
(
edit
)
Template:Code
(
edit
)
Template:Codett
(
edit
)
Template:Failed verification
(
edit
)
Template:IPAc-en
(
edit
)
Template:Infobox
(
edit
)
Template:Infobox software
(
edit
)
Template:Ken Thompson navbox
(
edit
)
Template:Lowercase
(
edit
)
Template:Main other
(
edit
)
Template:Man
(
edit
)
Template:Plan 9 commands
(
edit
)
Template:PreCode
(
edit
)
Template:R
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Sister project
(
edit
)
Template:Template other
(
edit
)
Template:Tt
(
edit
)
Template:Unix commands
(
edit
)
Template:Wikibooks
(
edit
)