Ed
The text editor ed was the original standard on the UNIX operating system. ed was originally written by Ken Thompson and he implemented regular expression in ed for the first time. Prior to that implementation, the concept of regular expressions was only formalized in a mathematical paper, which Ken Thompson had read. ed was influenced by an earlier editor known as QED from University of California at Berkeley, where Ken Thompson had graduated from. ed went on to influence ex, which in turn spawned vi. The non-interactive UNIX commands grep and sed were inspired by common special uses of ed; their influence is visible in the design of the programming language AWK, which in turn inspired aspects of Perl.
Explanation of the example
Here we started with an empty file, and used a to append text (all ed commands are single letters). That put us into insert mode, which is terminated by a singular dot on a line. The two lines that we entered before the dot end up in the file buffer. 2i 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 and will operate on that line.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
In 1,$l the l stands for the list command. This time we prefixed the command by a range, two lines separated by a comma ($ means the last line). In return, ed is listing 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.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
We will correct the error in line 3 with 3s/two/three/, a substitution command. The 3 will apply it to the right line, following the command is the text to be replaced, and then the replacement. Listing all lines again with 1,$l we see that the line is correct now.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
w text writes the buffer to the file "text". ed responds with 65, which is the number of characters that it wrote to the file. q will end our ed session.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ Table of Content ~
| ► | Introduction |
| ► | Example session |
| ► | Explanation of the example |
| ► | Bill Joy, vi, and ed |
| ► | External links |
~ What's Hot ~
~ Community ~
| ► | History Forum Come and discuss about History, Civilizations, Historical Events and Figures |
| ► | History Web-Ring A community of sites, blogs and forums dedicated to History. Do not hesitate to submit your site. |
and are licensed under the GNU Free Documentation License.
Lexicon - Privacy Policy - Spiritus-Temporis.com ©2005.