Hacker News new | past | comments | ask | show | jobs | submit login
ed(1) mastery is a must for a real Unix person (bsdly.blogspot.com)
49 points by sgt 6 months ago | hide | past | favorite | 70 comments



For those who don't notice straight away, the date on the article is April 1st.


Ok, good. I was so confused.

I thought this was like nerd supremacy but it does ring true: your text editor doesn't matter, you are not a better writer / programmer / person because of what editor you use.

I did thoroughly enjoy the dig about BSD supremacy. Those guys are worse than vegans and environmentalists. :)


> you are not a better writer / programmer / person because of what editor you use

somebody uses Emacs...

But seriously, the tribalism over which is better is ridiculous, but a good writer/programmer/person chooses their tools intentionally, and makes their tools work for them instead of against them. My choice of editor doesn't make me better than you, but it makes me better than a version of me using sub par tools that I have to fight to make work. It's about reaching flow state and being able to do work, and make work happen. If forced to cut down a tree in 5 minutes, the learned lumberjack will spend 3 sharpening their axe.


I mostly agree, however it seems that a certain core of editor controls has managed to spread and become a commonly available default in various products. The emacs shortcuts in particular seem to be available any place there is a text editor box like in browsers, in web IDEs, mainstream IDEs like VSCode or IntelliJ etc etc and as such I think it makes good sense to learn those just as a matter of education.


They’re associated with Emacs now but at least some of them seem to go back to TENEX: http://unix-kb.cat-v.org/


Emacs keybindings are even baked into NSText, the basis of everything to do with text handling in macOS.


A bit of an exaggeration because VSCode (on macOS or any other OS) for example does not recognize any Emacs keybindings.

Ditto textareas in Chrome and Firefox.


Yea like what's a fake unix person like?


Anyone who didn't start during the CRT era, when you couldn't even count on curses support in the terminal.

The "everything is a printer" abstraction started because PDP's that ran V7 Unix at Bell Labs really did use Teletypes for user interaction.

https://en.wikipedia.org/wiki/Teleprinter


Someone using WSL 2 on Windows 11, or a macOS user who only knows how to type "ls" in their terminal :-)


which seems silly given today is December 15.....


That book (Ed Mastery, https://mwl.io/nonfiction/tools#ed) is an April fool's joke, but it's a real book and I thought it was actually really good. I've still basically never used ed but it was fun to learn about and it helped me understand vim's history a little bit.


My favourite part about it is the "Manly McManface Edition" with masculine pronouns for double the price :D

https://www.tiltedwindmillpress.com/product/manly/


It has a prettier cover, too.


I did use ed, ever so briefly. I was introduced to it when my employer brought-out a new machine that ran SVID. We talked to it through glass teletypes.

The commands in vi are based around the commands in ed. They belong to the same family. sed is also a family-member, and an amazing tool. But I won't be sorry if I never run into ed again. Essentially, it's a rudimentary editor with zero dependencies; it doesn't need a curses library, in particular. And it would work on a terminal with only a printer for output, which was useful, back then.


I still use ed - Ed formatted patches are great for retro computing, I would very rarely use it interactively, but scripting with it is surprisingly useful.


I’ve used ed scripting in serious production work across thousands of hosts. It was nice to have that programmability but be able to “reason” with the entire file.


As an undergraduate we had to use ed for all our editing needs after we moved away from punch cards because vi was considered too resource-hungry. Four years of ed on an IBM 3101, and to this day 4 decades later I still prefer a green-on-black CLI interface and Cherry MX Green keys but use vim in big windows.

I can still get by using ed when I have to though.


I transpiled ed’s C code to Javascript so I could run it with node.js. Now I can finally run ed under Windows and replace notepad.exe.


Windows notepad possibly being the most prominent text editor that ed is unambiguously superior to.

Still blows my mind that projects like notepad++ have been around for the literal lifetime of younger users and somehow MS just did not give any sort of shit about their terrible editor.


It's purpose is be able to open a text file and encourage you to buy word and visual studio.

A user who has an grade F and many grade A and B options may not be better off if upgraded to a default D or C. In fact if they don't move on to one of the A options they may be worse off.


For me, its finest purpose is to be a buffer that I can paste formatted text into so that it can strip the formatting. There are many programs that do this natively, but there are many that don't or are really inconsistent about the hotkeys, and Notepad is always there.


“Notepad.exe too crappy for you? Buy Word!” This is why.


Word is a replacement for notepad like a chainsaw is a replacement for a pair of dressmaker's shears.

They do superficially similar jobs, but the similarities end the first time you try to use one for a job that requires the other.


I took one look at notepad++ and deleted it many years ago because the interface was cluttered and ugly. Notepad is fine for simple use cases.


> Notepad is fine for simple use cases.

Maybe now, I'm told it has been improved in windows 11. But for decades, it was the only "mainstream" text editor I'm aware of that didn't have multi-level undo/redo (that is, it remembers your last action, and that's it). The fact that it stuck around this long without that feature is amazing, really.

It's use is really limited to modifying ini/properties files, unless you really hate yourself (and many of us did in the 2000s with our "made in notepad" website banners)


That is awesome. This might be my weekend project to do something similar.


compile to Jscript instead and you won't need node.js.


If you know vi, you pretty much know ed, as this jokey article glancingly points out.

There is a bug in the article: i" vi(1) does offer a distinctly visual interface that only became possible with the advent of the video terminal, affectionately known as the glass teletype."

The term "glass teletype" was coined specifically once there were terminals with addressable displays (that is, your program could place a character at any character position on the display at location X,Y). Until then displays drew at the bottom of the screen and scrolled the entire display upwards when receiving a line feed. Basically like a teletype!

The blog author has a white beard so could potentially be old enough to remember those days, but also is in Norway so the slang could have been shorn of its roots in the process of crossing the Atlantic.


Not just teletypes. Most BBS systems (1980s) didn't have a good way to control the remote screen and so they ended up acting like they were printing to paper despite having a full terminal on the other end. I did use a teletype in the early 1990s to call a BBS (via acoustic coupler) - when lightening took out my computer. Other than the waste of paper is worked just fine. Unfortunately none of them provided an editor near as good as ed - but as a kid I didn't know what I was missing.

I've also had to configure equipment that only provided a serial port. Some let me configure TERM, but others did not. Either way I knew ed and so figuring out how to configure TERM wasn't worth the bother for quick changes.

Even in the late 1990s, computers were sometimes slow enough that for quick changes I could open ed and make the change faster than vi could load. Don't get me started on loading emacs on those (which most people did and probably why ed was faster)


Arguably, interactive editing with "ed" is an obsolete skill that went out with 110baud mechanical teletypes.

However, having a basic idea of "sed" is a goldmine for super-quick command line pipeline kinds of tricks. Even in this day and age.


It remained a valuable skill into the 1990s when many UNIX machines still had a separate /usr partition.

Many times I'd have to fix a server with a configuration issue causing /usr to not mount correctly on boot. When you're at a single-user shell and no /usr/bin/vi is available suddenly knowing the basics of /bin/ed becomes very useful.

Of course these days most UNIXes moved away from a separate /usr partition so if the root filesystem mounts you have a full-featured vim.


ed also was, at least on LPMuds in the 90s, the only online editor. It was a bit crippled, but still recognizably ed.


PSA if you use sed with anything but trivial patterns, consider supplying the pattern via file `sed -f script.sed`. Saves you a lot of sanity not having to escape everything in arcane shell + regex escape rules.


I used ed on video terminals connected to VME 68000 Unix V7 machines around 1986. For some reason, I don't remember using vi on them, and in any case, ed remained very useful when the terminal type was misconfigured or unknown to the system, which happened quite a lot (I guess that not everything emulated a VT100 at the time). We actually jumped directly from ed to some Emacs relative (Jove probably), which was the beginning of paradise, and then we received our Sun 3 and it was Emacs all the way to present :)


vi is painful over slow lines, maybe that was it? When I started at SCO in '86 my terminal connected at 9600 baud to a VME 68000 box named "scotty" running Xenix. (All our servers had names containing "sco". Over the years I think we had to settle for just having the letters somewhere in the name.) 9600 baud was luxury after university, where all our terminals connected at 2400 baud.


ed is still great if I just want to fix a few lines remotely over a terminal. You might say ed is interactive sed :)


Ironically I’m studying all the oldest of oldest UNIX utilities that can work well over a pure teletype style terminal, think a LA34 DECwriter IV. No ncurses, no TUI. only line feeds and also ink is scarce.

Why? Because we have a new friend in the house who effectively has to interact with the outside world via teletype terminal.

The LLMs!


A great point, but even over a teletype you'd use "ex", not "ed".


Totally true! Thank you for reminding me of ex.


Curious: Why would you use ed over ex, or vi for that matter?


"ed" is easier to type than "ex" but mostly it's a matter of habit. On some systems, /bin/ed is a separate binary but /usr/bin/ex is actually just a symlink to vim, and at that point I might as well run vim.

As to why I run "ed" instead of "vi": if I get just a few errors from some script I just copied over, I could run "ed" and the error message is still on the screen (because ed doesn't repaint the whole screen). I would run vi and screen if I expect to fix more than just a few lines.


makes sense


sed and vi both have roots in ed, right? So you only needed one more round of advancement from ed to reach peak computing.

I mean we’re all joking in this thread to some extent, but actually, I don’t know that I don’t believe this.


> sed and vi both have roots in ed

A joke I used to tell people is "don't know how to quit vi? Just type Q to enter Ex mode, then you can exit vi just like how you would exit ed."


Clearly the solution is :!killall vi or something along those lines.


ed is useful in one specific circumstance, but it's useful enough in that circumstance that I recommend it to anyone who's really serious about unix shell scripting.

In the context of a shell script, there are things you can do with ed and a here document that are extremely difficult to do any other way. For example, I had to recover my website from the wayback machine during covid lockdown (long story).

I decided to change everything to markdown and wanted to add yaml frontmatter to every one of a hundred or so markdown files. The Yaml frontmatter needed to be different for each file and I ended up having to make various tweaks before I brought it back live.

So, ... multiple times I had to do edits like "in the fourth line above the -- that ends the yaml front matter, change x to y". This is a very tough edit to make with the usual suspects (sed/perl/awk etc), but is a breeze to do if you run ed in your shell script and have the commands you want to run supplied by a here doc.


I still use for ed non-interactively moving and deleting lines in large text files, e.g., lists, and have not come across anything that I think is better.

I use sed for non-interactve editing as well. Below is a favourite of script of mine ("ins") that I use frequently for non-interactively inserting text at the top or at any line in text files.

     #!/bin/sh
     case $# in :)
     ;;0) exec echo usage: ${0##*/} target \[line-no\]
     ;;[12]) sed -i -e ${2-1}r/dev/stdin -e1N $1
     esac
Stupid examples:

     echo 93.184.216.34 example.com|ins /etc/hosts

     cat 84*.c|ins 084.l 151 # insert some .c files at line 151


For those curious how it actually looks like when a skilled person uses it: https://www.youtube.com/watch?v=BNYpmLH6IjQ


Reminds me of the classic "Ed, man! !man ed"

https://www.gnu.org/fun/jokes/ed-msg.html


ED IS THE STANDARD!!!

TEXT EDITOR.



Kernighan and Ritchie wrote the 1st edition of their book with ed and troff, didn't they?


There are many text editors but only one standard.


Ed is the standard text editor, after all.


I understand this is an April Fool's joke and is intended to be satire, but I don't think that's made clear enough in the text. There's risk that a junior engineer or student reading this will misunderstand it as sincere, and be dissuaded from technical work altogether.

Make no mistake, there are plenty of people in our industry who hold genuine opinions like this and are more than happy to bash less experienced people for trivial tool choices.


Poe's law strikes again! That risk is real, but a student who isn't open enough to express that they read this to their professor and classmates, and that they read it seriously, is likely to have problems in other fields as well.


> Your choice of text editor is a serious matter.

No, it's not. It really doesn't matter at all what editor you use. And there are so many to choose from. You don't even need to stick to only one editor. I sure as hell don't.

Editor loyalty is tribalism, and tribalism is myopic. Use whatever tool gets the damn job done, and learn a few of them so that you at least know what's possible.


What you're saying is true, but for context the article is an old April fool's joke. Not sure why it was posted today.


There was a time that ed was necessary knowledge because you often had richer editors installed on a different partition from the boot partition and more frequently than you would expect you ended up in a position where you were only able to bring up the boot partition or had to boot emergency media, both of which only had ed. That wasn’t a preference thing, it was a necessity thing. Trying to learn how to use ed when production is down (and you might not have a readily available command window with man pages available when you’re in a data center on a vt220 plugged into the dead system!)


Editor loyalty is more than tribalism. The more/better you know your editor, the quicker you can make some complex edits of the type that editor enables. Of course some editors are more limiting than others, so you can master notepad in an a short time - though it probably isn't worth the bother even though it can insert the date/time into your document (as I just discovered while writing this), the limited functions means if you need that feature you should already be using a different editor that provides other features it doesn't.

However be careful. Editors do offer different features. Some things really are easier/better in a different editor, thus even after you settled on an editor you should - every few years - take a look around to see if maybe something else is enough better in some way as to be worth learning in depth. While sometimes it seems like the wrong choice will get the other tribe to kill you (or condemn you to hell for eternity), I'm not aware of that ever happening - generally you can remain friends with other people after switching.


You are in error, ed(1) is the standard Unix text editor.

But seriously, you fell for an April Fools' joke.


Use whatever get the job done.

It's fine to use Vscode, but it's nice to know emacs/vim/nano, it's very nice to know ed/vi, but it's really nice to not have to use echo.


check the publication date.


2018? Maybe in 1998.


April 1st.


I think this is the worst straw man headline I've ever heard.

I've never actually used ed once in the last 30 years of using Unixes both on a programming and admin perspective.

Edit: ok he got me :)


Many long years ago I took a course that required using a terminal to edit and run code (Language was Dartmouth Basic.) One lucky student got to use a full screen terminal while the rest of us used some kind of line oriented terminal. My recollection is the DEC LA120 (Though this was on a Prime 300 mini.) The only way to edit code was using a line oriented editor. (Though not technically ed on UNIX.)

We have come so far since.


I've been using Ed to write assembly on my Kaypro since it's so much faster than WordStar. It's been interesting seeing how people used to do it.


[2018]




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: