11

I'm wondering if the ed editor is useful any longer for interactive editing. I know that the diff command can produce patches as ed scripts and that ed is a last resort when the baud rate is super slow. But are there any other reasons to learn and use ed?

5 Answers 5

10

As a general purpose editor, probably not, but as a way to get yourself out of a pinch, it's good to know a few basics. The good news is that if you know your way around vim, it's likely you can use that knowledge to blunder around in ed. The times are changing, but there are still systems that it might be your best editor or connection scenarios that call for it. I've used it from my super-slick smartphone logged into a modern linux box when the connection was bad enough that running a full editor was taking forever and I really needed to just change a line and get out.

2
  • I personally favor ex over ed; although both are specified by POSIX, ex has a lot more features, and is actually often the same binary as vi (since vi is the "visual editor" for ex).
    – Wildcard
    Dec 12, 2016 at 2:24
  • 1
    My favorite reason to use ed is because when I'm doing a working session in the terminal I don't like when the full screen editor takes up the full screen, then disappears after I close the editor. With ed, I can keep the context of what I was working on in plain view. To keep track of any changes I made, I simply scroll back; for example, I might grep a file and find where I want to change, edit the file with ed, restart a service, grep logs, edit another file; then think: Oh what happened, so I can scroll back and check the precise changes (all from one terminal)—it's fun!
    – mbigras
    Jan 22 at 7:41
3

If you happen to be working on a terminal that doesn't support fancy things like scrollback (for example, an actual teletype), then ed really shines.

0

I've been known to occasionally use ex (vi in non visual mode, not ed) to do small edition when logged remotely through a high latency line (and I put then telnet in line mode). Bigger edition and I'm using emacs locally. The dismiss of telnet in favor of ssh even for inside the intranet remote session has been the raison I stopped doing that.

A long time ago, I've used a line editor on a this kind of terminals; it wasn't ed nor ex.

-1

I've used ed to non-interactively rotate my copy of a task list file, supporting #comments.

From https://github.com/waltinator/net-o-matic:

By this time, my copy of the config file has been checked to ensure at least 1 non-#comment, non-blank line exists.

function flip () {
    # Return the first non-blank, non #comment line,
    # and move that line (and all preceeding blank and #comment
    # lines) to the end of (our copy of) the config file.
    #
    # ed pattern includes "/", but not "~" or "."
    #Adjust the ed pattern in both places and in countconfiglines
    ed --quiet "$config" <<EndOfEd
/^[A-Za-z0-9\/]/
1,.t$
1,/^[A-Za-z0-9\/]/d
wq
EndOfEd
}

Is there a better way?

Also in my professional career as a sysadmin/computer security geek (~50 years), the knowledge of ed, an editor that will work over a 110 baud TeleType, as a backup, has been reassuring. My editor choices are :emacs,vim, vi,nano, ed, teco.

-2

ed is great for all kinds of editing and fun to use.

vim and emacs are a little too complicated.

2
  • I guess this is ment as a joke and does not help (-1) Dec 15, 2011 at 12:28
  • 3
    I'm tempted to call it not an answer, but I'm rolling with "vim and emacs are a little too complicated" as a reason to use ed. Some more information would certainly be useful though Dec 15, 2011 at 18:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .