ed (Texteditor)

Ed is (no matter how old or new) of available text editor that can be used interactively or within shell scripts for processing text files a similar on all Unix and Unix systems.

As the editors ex and vi ed is line -oriented: The text editing always refers to a row or a range of rows. In contrast to the vi ed provides the interactive use a single line for editing, ie it is not possible to move vertically through the text.

Like the other editors mentioned has ed a writing and a command mode. In write mode, the entered character on the line that is currently being edited, added. In command mode, typed characters are interpreted as an edit, view, store or shell commands. Text corrections or replacements - made ​​esp. via pattern search using regular expressions.

Ed only consumes little memory resources need to perform any special program libraries and works with any type of terminal. ed is as usually the only editor in the first Binaries directory of the directory tree ( / bin ) and can therefore always be called when ever a program can be executed. The modesty of the editor and its reliable availability and accessibility are the most important aspects in which it is interesting even today, especially for system administrators. Because the ed after the call at first only one line of the screen asks for himself, he is sometimes useful when a particular change to be made, for example, in a shell script, you do not but at the same screen output of the last started process want to lose sight of. In addition, programs can call without circumstance from the editor: The screen output of the program is again visible, and you can edit the line further ado, worked on the before calling the program.


Ed is about as old as Unix, but has been a forerunner in the first character-oriented, later line-oriented editor QED, which was programmed mid-1960s and from which there were different versions on different systems. ed was written in the early 1970s by Ken Thompson. Neither the functionality nor in the appearance he has materially changed since then. Non-interactive character stream editor sed inherits the ed in one of its basic functions and expanding them. Unlike sed ed first reads the whole file into memory before executing the specified commands. The line-oriented editor ex, which forms the basis of vi, has been inspired by ed. The Plan 9 editor sam resembles ed, however, breaks with the line orientation and is designed primarily as a visual editor.


The interactive use of ed can be found in detail ( man pages ) described each Unix ( -like ) system in the manual pages. The following example demonstrates from the non-interactive use of a shell script:

Ed -s FILE! << 1, $ s / vi / ex / g w q! In the example ed is called with the FILE file to which a specified than Heredoc ed command sequence is used:

The-s option ( for script or suppress, English suppressive. ) Suppresses the status outputs. This is in non-interactive use usually desired.