Quick links About ed / red Syntax Examples Related commands Linux / Unix main page About ed Line oriented file editor. Below is a listing of know limitations of the ed editor:
64 characters per file name.
256 characters per global subcommand list.
LINE_MAX characters per line (although there is currently a system-imposed limit of 255 characters per line entered from the keyboard).
128,000 character buffer size,
Syntax ed [-C] [-p string] [-s] [-] [-x] filename red [-C] [-p string] [-s | - ] [-x] filename
| -C | Encryption option; the same as the -x option, except that ed simulates a C command. The C command is like the X command, except that all text read in is assumed to have been encrypted. |
| -p string | Allows the user to specify a prompt string. By default, there is no prompt string. |
| -s or - | Suppresses the writing of character counts by e, r, and w commands, of diagnostics from e and q commands, and of the ! prompt after a !shell command. |
| -x | Encryption option; when used, ed simulates an X command and prompts the user for a key. The X command makes an educated guess to determine whether text read in is encrypted or not. The temporary buffer file is encrypted also, using a transformed version of the key typed in for the -x option. |
| filename | The name of the file that you wish to edit. |
Examples Assuming the file myfile.txt has the following lines in it: Hello world this is a test of the ed editor ed myfile.txt - Would open the file myfile.txt in the ed editor. Below is examples of how you could navigate with the ed command.
| $ | Reads the last line in this case "of the ed editor" |
| - | Moves back one line. For example, if $ was typed, if - was entered would move up to "this is a test". A number can be added to move more than one line at a time. For example, if at the last line typing -2 would move back to the first line in this example. |
| + | The + moves one line forward instead of back like the -. Like the - the + can have a number added after it, for example, +2 to move two lines instead of one line. |
| /. | Reads the first line in this case "Hello world" additional dots can be added to read other lines. |
| /text/ | Searches for the text typed in-between the forward slashes and displays the next line that has this text. For example, if we were at the first line "Hello world" and typed /test/ the line displayed would be "this is a test" |
| i | Inserts text above the current line. Once you are done inserting text press CTRL + C to exit out of the insert option. |
| j | Joins lines of text. |
| t | Copies the line. |
| c | Used to change text. For example, if our current line was "this is a test". Typing c would allow you to enter a new line. Typing "this is a tester" and then pressing CTRL + C would replace the previous line with this new line. |
| r | Removes the specific line you are currently on. |
| X | Allows you to skip to a line. For example, typing X and when asked to enter a key you enter 3 would display the line "of the ed editor" |
Additionally many of the above options can be combined. For example, typing /test/i would insert a line before the first line that has test. Related commands bfs cat edit ex grep ksh pico sed sh stty umask vi vim | |
| Resolved |
Were you able to locate the answer to your questions?
|
| |