| Previous | Table of Contents | Next |
DIAGNOSTICS AND BUGS
ed has very brief and usually useless error messages. Fortunately, there usually isn't too much to explain with a line editor.
| ? | Indicates that you made a mistake on the edit command. Usually, you have a syntax problem. Check the edit command format and try again. Turn on the help feature by typing H and pressing Return. |
| ?file | Indicates that ed could not read or write to the specified file. You might receive this message when using the e, r, and w commands. It usually means the file exists and you do not have read or write permissions (whatever the case may be). It may mean you do not have read or write permissions for the directory. In some instances it could also mean the file system is out of disk space. Try the !df command to verify disk space is available. |
RELATED COMMANDS
Refer to the nawk, ex, sed, and vi commands described in modules 6, 43, 117, and 151.
RELATED FILES
The editor uses several files and directories while you are editing.
| /var/tmp | The directory where the temporary file buffer is stored. |
| TMPDIR | The shell variable containing the name of the directory to use instead of the default /var/tmp directory. If the variable is set, the specified path is used; otherwise, /var/tmp is used. |
| ed.hup | The contents of the buffer are saved to this file if the line hangs up (you get disconnected from the system). This is usually caused by a phone line or modem problem, although even direct cabling has been know to be pulled loose from the computer or terminal by clumsy people. |
APPLICATIONS
The ed editor can be used to create new text files or update existing ones. It is a fairly powerful line editor. Although most computer users have moved to screen editors, there is still a need for line editors. The most common use is in shell scripts. It is often necessary to make changes to a file from within a shell script. The easiest way to do this may be by using a line editor like ed. One thing that sets UNIX editors apart from most editors is the rich set of wild cards, called Regular Expressions on UNIX. Regular Expressions allow you to match almost any existing string of text you can imagine.
You may find the need to use a line editor when you cannot figure out what the proper terminal type is for a certain terminal you are using. Until you find out the terminal type you cannot use the vi screen editor. Therefore, it is a good idea to know a little about the line editors just in case you get in a time squeeze and are forced to do some editing before you can use vi.
TYPICAL OPERATION
In this activity you use the ed command to create and modify a text file. Begin at the shell prompt.
cj> ed ed_file
?ed_file
_
cj> ed ed_file
?ed_file
a
cj> ed ed_file
?ed_file
a
This is a new file created by the ed editor.
It is a line editor.
I prefer the screen editor.
But I need to know how to use this editor in certain situations.
Time to return to the command mode.
cj> ed -p "ed " ed_file
195
ed>
ed> ,p
This is a new file created by the ed editor.
I prefer the screen editor.
But I need to know how to use this editor in certain situations.
This is a newly inserted line of text.
Time to return to the command mode.
ed> 1s/ new/n existing/p
This is an existing file created by the ed editor.
ed> ,p
But I need to know how to use this editor in certain situations.
This is a newly inserted line of text.
This is an existing file created by the ed editor.
I prefer the screen editor.
Time to return to the command mode.
| Previous | Table of Contents | Next |