Ed is the simplest text editing program in Linux. It can only edit one row at a time rather than the full screen mode.
The ed command is not a common command. Generally, the vi command is used. However, the ed text editor is useful for editing large files or text editing in shell scripts.
Syntax
Ed [-] [-Gs] [-p <string>] [-- help] [-- version] [file]
Parameters:
- -G or -- traditional provides the back-compatible function.
- -P <string> specifies the prompt character of ed in command mode.
- -S,-, -- quiet or -- silent does not perform the check function when the file is enabled.
- -- Help: displays help.
- -- Version: displays the version information.
Instance
The following is a complete Linux ed instance resolution:
$ Ed <-activate ed command
A <-tell ed that I want to edit the new file
My name is Titan. <-enter the content of the first line.
And I love Perl very much. <-enter the second line of content
. <-Return the command line status of ed
I <-tell ed that I want to insert content before the last line
I am 24. <-insert "I am 24." between "My name is Titan." And "And I love Perl very much."
. <-Return the command line status of ed
C <-tell ed that I want to replace the last input line
I am 24 years old. <-replace "I am 24." with "I am 24 years old." (note: The Last input is replaced here)
. <-Return the command line status of ed
W readme. text <-name the file "readme. text" and save it. (Note: If you are editing an existing file, you only need to enter w)
Q <-exit the ed editor completely
The content of this file is:
$ Cat readme. text
My name is Titan.
I am 24 years old.
And I love Perl vrey much.