TheBestLinks.com
TheBestLinks.com
Ed, Awk, Computer printer, Hard disk, Linux, Modem, Qed text editor, RAM, Sed... Print friendly version | Tell a friend
 
Navigation
Search
Toolbox

Ed

From TheBestLinks.com

The text editor ed was the original standard on the UNIX operating system. It was influenced by an earlier editor known as qed, and 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.

Famous for its terseness, ed has almost no visual feedback. For example, the message that ed will produce in case of error, or when it wants to make sure you want 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. This terseness was appropriate in the early versions of UNIX, when consoles were printers, modems were slow, and hard disk and memory were precious, but these advantages ceased to apply when more interactive editors became the standards.

In current practice ed is almost never used interactively, but it does find use in some shell scripts. For interactive use, ed was subsumed by vi and emacs editors in the 1980s. ed can be found on virtually every version of UNIX and Linux available; people who have to work with multiple versions of UNIX often know at least the basic ed commands.

Example session

Here is an example transcript of an ed session:

 a
 ed is the standard UNIX text editor.
 This is line number two.
 .
 2i
   
 .
 1,$l
 ed is the standard UNIX text editor.$
 $
 This is line number two.$
 3s/two/three/
 1,$l
 ed is the standard UNIX text editor.$
 $
 This is line number three.$
 w text
 65
 q

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.

External Links


it:ed

Related links


Top visited 0 of 0 links

[no links posted yet]

>> place link >>

Discussion

Last posted 0 of 0 messages

[no messages posted yet]

>> post message >>

Watch

You can add this article to your own "watchlist" and receive e-mail notification about all changes in this page.
 
   
Innovate it
This page was last modified 22:34, 8 Sep 2004.
  Content is available under GNU Free Documentation License 1.2.
Powered by MediaWiki