Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Ed (software)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Ed (software)
(section)
Add topic