Ed Is The Standard Text Editor for Unix/Linux

What the title states is not at all obvious these days, and yet if you look at the man page for ed, it says (and I quote the following): “ed is the ‘standard’ text editor in the sense that it is the original editor for Unix, and thus widely available. For most purposes, however, it is superseded by full-screen editors such as GNU Emacs or GNU Moe.”

Distro Tube writes about this one and even mentions two options I did not know existed: the -p command option to set a prompt, and the :H directive to generate errors in addition to the super terse ?

I checked it out and indeed ed -p “:” thoughts.txt
brings up my file called thoughts.txt and returns a : prompt.

An illegal command generates “Unknown command” if I feed it a b, which is not an ed command. If I say 4000 and my file is not 4000 or more lines long, with the : prompt and the H command implemented, I get the response: “Invalid address”. Before today I did not realize either of these capabilities!

Ed Is the Standard Text Editor for Unix/Linux

3 Likes

I have never heard or seen any indication of the existence of that editor. It may be arrogant on my part, but even after reading the description at Savannah, I feel confident in saying that I can quickly forget about it and not worry of consequences. :slight_smile:



ed is so stripped down, similar to the old MS-DOS EDIT that, for me, it is useless. Yes, I am aware that there are some “use cases” where such a “line editor” is required but, except for back in 1986, I have not come across a single such instance since then!

I will stick to good old vi/GVim, thank you!

:slight_smile:

2 Likes

To be honest, I’ve never used ed often either. However, I did find at least one scenario where I did use it. Here are two examples: one when I was ready to use something else and another admittedly rare case when I actually found it to be useful.

First the “wish I had something else case”. I was new to Unix and I was at a Bell Systems training facility, getting to know Unix. In a lab, all I knew was ed, but I wasn’t very good with it and it’s not all that easy to see what’s on your screen. Fortunately someone showed me vi; though vi isn’t necessarily “easy” in every possible way, I learned just enough keystrokes to get the labs done much easier than with ed.

Okay, so we’ve established that ed is not the most intuitive tool or the most powerful editor, so when might I actually find a use for it? Well, there are other tools to do what I actually got a use, but sometimes they are either not available or they’re difficult to master; that’s where ed turned out to be fine.

I wanted to simply get in and substitute one value for another across a document. Vi may have worked, Perl, sed, awk, or gawk would arguably do a more complete job, but sed can be tricky since the default is stdin and stdout, Perl, awk and gawk are more complicated, but ed has a limited, straightforward command set, so it turned out to be a quick, easy solution.

Could I have used something else, including vi or Emacs? Probably, but doing it with ed was fast, quick and the job was done within a minute or two, so I felt that made it a useful tool for that specific case; can’t honestly say I’ve needed to do that very often, but it sure did come in handy that one time when I had an unusual brain freeze on other approaches!

One other rare scenario is when a system is crippled and a lot of features do not work; most of the time vi is still available, but it’s possible that ed, as a standard utility, may be one of the last things to go. I’ve got a lot of other editors in my arsenal and I hadn’t touched ed in years, but I did try a few things and in the limited capacity of a “line editor” rather than a “screen editor”, it is useful for rare scenarios where a line by line tool is what’s called for. That’d probably be on some ancient 20-40 year old hardware; I have a few friends that actually relish working with these; that ancient stuff might present a few of those rarely seen use cases, other than that, yeah, this is more of a historical thing than a practical every day tool in use today.

The guy I enjoy the most, “Distro Tube”, decided to rank 14 text editing tools, a few of them are IDE (Integrated Development Environments) that include editing, some are just plain text editors.
The Text Editor Tier List (Open Source Editors ONLY!)

Just so you know, DT ranked Atom, Ed, and Gvim as YUCK, though he did rate Emacs, Neovim and Vim as GREAT. This is my update for Tuesday, June 16m since I’ve tacked onto this note a couple of times now!

4 Likes