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?
- 320,670
- 36
- 633
- 936
- 4,007
- 5
- 26
- 34
5 Answers
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.
- 69,278
- 18
- 196
- 226
-
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 '16 at 02:24
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.
- 10,884
- 4
- 33
- 45
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.
- 2,278
- 18
- 15
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.
- 4,439
- 1
- 16
- 21
ed is great for all kinds of editing and fun to use.
vim and emacs are a little too complicated.
-
-
3I'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 – Michael Mrozek Dec 15 '11 at 18:03