ed command in Linux is used for launching the ed text editor which is a line-based text editor with a minimal interface which makes it less complex for working on text files i.e creating, editing, displaying and manipulating files. It is the oldest editor built in the Unix. It is succeeded by vi and emacs text editor.
Syntax:
ed [options] [file]
ed command without any option: It will launch the ed editor with an empty buffer for us to write, this is similar to the other visual or command line based editor when invoked without a filename. The simplest way to start the ed text editor is by typing “ed” into the terminal.
Example 1:

Here we have not specified the filename so this will create an empty buffer for us to write.
Example 2: To Enter into insert mode press “a” and when you are done writing stop it by “.” (dot).

Example 3: To view, the last line enter “p” into the ed command prompt.

Example 4: To print all the lines that we inserted in the buffer by using “, p”.

Example 5: To save these lines into a file write “f [filename]”.

Example 6: Type “w” in ed command prompt to write the data into the file and see how many bytes are written.

Example 7: The file now has data and we can exit to the terminal by pressing “Q” at ed command prompt.

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!
Looking for a place to share your ideas, learn, and connect? Our Community portal is just the spot! Come join us and see what all the buzz is about!
Last Updated :
15 May, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...