I'm glad ed is there. I'm glad articles like this are there. But there is no way I'll have retained that article in the moment my terminal has borked and I actually need ed. I wish that something like this available in the man pages, or something like them, or at least referred to in them. Because maybe I'm not clever enough but I don't find the man page articles to be very good introductions. As reminders of syntax…
On many systems you should be able to unbork the terminal with 'reset' or 'tput reset'. Then you do not need ed ;)
Actually using Ed
81–90 of 92 posts
Re: Actually using Ed
#82Having been a user of *NIX for over 20 years and a professional Systems Administrator for over 10, I have never once had a reason to use ed. Even the smallest embedded environments usually have some variant of vi available. The only time that I've needed to use ed was edlin in the dark days of early MS-DOS, which is very similar. This is borderline masochistic.
Re: Actually using Ed
#83Earlier quoted context omitted.
Even today 'ed' has practical uses apart from being the default emergency backup of the backup editor. One situation where I always use 'ed' is when I reinstall a machine (with the same ip) and ssh tells me the keys don't match together with the line number in the file known_hosts. It's easy as: #ed ~/.ssh/known_hosts 15d wq (assuming the mismatching line was 15). Only sed would be faster if it wasn't for the time sp…
Learn ed so that vi becomes easier - nice joke! More relevant is that I already know a bunch of tools for doing deletion of line 5. For example: perl -i -ne 'print unless $.==15' . It's more complicated, but it's a smaller number of tools for me to remember. Actually, I probably would have used mv to a temp file + awk 'NR!=15' + rm temp file. Even knowing perl and python I still use awk pretty often, and it comes to…
Re: Actually using Ed
#84I think sed pretty much displaced ed. I still use ed but sed offers the same functionality and it's easier to script. One exception is the j command for joining lines. For better or worse, in some of today's base Linux distributions, you might find ed missing. You will almost always find sed though.
Re: Actually using Ed
#85Earlier quoted context omitted.
not a joke at all. A regex you use in 'ed' command mode, you can use directly in vi after typing ':' I never made any heavy use of 'vi', but I can use it because I know a little 'ed'. Conversely, if one knows 'vi', it's easy to use 'ed' when one needs a tiny edit and doesn't want the whole screen to be filled. Even though it's just a moment, I find it distracting, especially in the ssh case I mentioned where I expect…
The only vi editor I used for more than a version commit was 'elvis' on Minux. Otherwise I'm an emacs user. (I know "q", "q!", "s", "dd", "i", "/", and "a". That's all I need for commits.) The reason I found it humorous is my difficulty in coming up with strong reasons for someone to start with ed and then transition to vi, while it's easy to come up with reasons to start with vi and then learn ed. And your best case…
As to what sysadmin jobs call for, having knowledge of 'ed' is not something I would put in the requirements, but it is something I would ask during an interview as it would hint at knowledge of the myriad of obscure tools that unix has, and/or having tackled delicate problems that would have required a fallback to 'ed' in the past.
As such we're mostly in agreement I think. I agree there are no compelling reasons for learning 'ed' as your primary text-editor. But there are compelling reasons against not having a working knowledge of 'ed', although it depends to a large extent on your field of endeavour.
Re: Actually using Ed
#86I think sed pretty much displaced ed. I still use ed but sed offers the same functionality and it's easier to script. One exception is the j command for joining lines. For better or worse, in some of today's base Linux distributions, you might find ed missing. You will almost always find sed though.
sed is great but it's a stream editor; try moving the last line to the start of the file.
Re: Actually using Ed
#87Re: Actually using Ed
#88Earlier quoted context omitted.
What better alternatives are there? Even if you prefer vi for interactive edits, I still prefer ed for small edits. Then there are times when your terminal is borken (or as somebody mentioned, perhaps even your keyboard is broken), this still happens more often than you think. Recently I had to use some ajax-term thing which was just awful and completely unable to run vi properly for who knows what reason, anything t…
I'm honestly curious - what's a use case for scripting the editing of files that's not better satisfied by using a scripting language? I see the value of Arch's focus on minimalism more than keeping ed around in this case, but I'm happy to be wrong. If your terminal is broken, there are plenty of ways (reset, stty sane, whatever) to fix that. I'm also not sure why having an extra binary on my system is a good safety…
Ed reads the entire file. If you need to move back and forth through the file, or move lines from one place to another, or reprocess the same line repeatedly, it can be far more convenient than a scripting language.
Re: Actually using Ed
#89Earlier quoted context omitted.
I don't know if unix is the most ahem "specific" specification ever given. What specification of unix do you think the author was referring to? In any case, they have corrected themselves in the blogpost.
well, if he was referring to 'unix' as specified in the Single Unix Specification (which incorporates IEEE Std 1003.1) then all unix systems have 'ed' http://pubs.opengroup.org/onlinepubs/009695399/utilities/ed.... If arch linux doesn't include it, it's not a 'unix'; it's not even a good "not unix". So the author wouldn't have needed to correct his article but Arch would need to include 'ed' :)
> If arch linux doesn't include it, it's not a 'unix'
...but according to that version of SUS, I'm sure the original unix isn't unix either. In any case, I don't think you can just assume any particular spec when someone says the word 'unix', most people usually just mean *nix-family (and if the spec is relevant they'll probably cite it).
> it's not even a good "not unix". I imagine arch is much closer to compliance if you install everything in the 'core' repository (which is recommended and includes ed). In any case, if lacking ed makes something a "bad not unix", I'm not sure most people mind being wrong ;)
Re: Actually using Ed
#90Having been a user of *NIX for over 20 years and a professional Systems Administrator for over 10, I have never once had a reason to use ed. Even the smallest embedded environments usually have some variant of vi available. The only time that I've needed to use ed was edlin in the dark days of early MS-DOS, which is very similar. This is borderline masochistic.
DOS's edlin is a very crude line editor, unlike ed(1) which has regular expressions, the g// command, etc.