Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Ed (software)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Example == Here is an example transcript of an ed session. For clarity, commands and text typed by the user are in normal [[Typeface|face]], and output from ed is '''emphasized'''. a {{as written|ed is the standard Unix text editor.}} This is line number two. . 2i<br> . ,l '''ed is the standard Unix text editor.$''' '''$''' '''This is line number two.$''' w text.txt '''63''' {{codett|2=sed|3s/two/three/}} ,l '''ed is the standard Unix text editor.$''' '''$''' '''This is line number three.$''' w text.txt '''65''' q The end result is a simple text file <code>text.txt</code> containing the following text: ed is the standard Unix text editor.<br> This is line number three. Started with an empty file, the <code>a</code> command appends text (all ed commands are single letters). The command puts ed in ''insert mode'', inserting the characters that follow and is terminated by a single dot on a line. The two lines that are entered before the dot end up in the file buffer. The <code>2i</code> command also 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 to operate on that line. In the line <code>,l</code>, the lowercase L stands for the list command. The command is prefixed by a range, in this case <code>,</code> which is a shortcut for <code>1,$</code>. A range is two line numbers separated by a comma (<code>$</code> means the last line). In return, ed lists 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. Once the empty line is inserted in line 2, the line which reads "This is line number two." is now actually the third line. This error is corrected with {{code|2=sed|3s/two/three/}}, a substitution command. The <code>3</code> will apply it to the correct line; following the command is the text to be replaced, and then the replacement. Listing all lines with <code>,l</code> the line is shown now to be correct. <code>w text.txt</code> writes the buffer to the file <code>text.txt</code> making ed respond with ''65'', the number of characters written to the file. <code>q</code> will end an ed session.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)