Live data from Hacker News

Actually using Ed

blog.sanctum.geek.nz

1–10 of 92 posts

Re: Actually using Ed

#5
I use ed frequently for writing quick scripts. Its edge is that you can use it while retaining visual history of the prompt.

Though, you could instead just redirect cat to a file and then do any tidy-up in your usual editor.

It's also sometimes useful when you're in a remote system that is behaving strangely due to screwed-up terminal definitions or some other catastrophe.

I'd be interested to read a sam tutorial focussed on using just the console version of the tool (i.e. not using the windowing system). I understand it takes a lot of ed's features and beefs them up.

Re: Actually using Ed

#7
post #5

I use ed frequently for writing quick scripts. Its edge is that you can use it while retaining visual history of the prompt. Though, you could instead just redirect cat to a file and then do any tidy-up in your usual editor. It's also sometimes useful when you're in a remote system that is behaving strangely due to screwed-up terminal definitions or some other catastrophe. I'd be interested to read a sam tutorial foc…

I do so as well. Most often it is sudo ed /etc/hosts.

Re: Actually using Ed

#8
post #5

I use ed frequently for writing quick scripts. Its edge is that you can use it while retaining visual history of the prompt. Though, you could instead just redirect cat to a file and then do any tidy-up in your usual editor. It's also sometimes useful when you're in a remote system that is behaving strangely due to screwed-up terminal definitions or some other catastrophe. I'd be interested to read a sam tutorial foc…

A Sam language tutorial by Rob Pike:

http://doc.cat-v.org/bell_labs/sam_lang_tutorial/

A cool thing about sam is that it has a client-server design, so you can run the GUI on your local system and still edit stuff remotely. This works very well even over very high latency connections.

See the -r flag: http://man.cat-v.org/p9p/1/sam

I still use ed for any short/small edits, it is hard to beat.

It works even better if you have a terminal like in rio/9term where you can edit/send history very easily.

cat also works quite well in such terminals thanks to 'hold mode' (cat > foo, press Esc, edit your text freely, press Esc again and ^D).

Re: Actually using Ed

#9
post #2

That was a good explanation. I hope never to have to use ed.

You may occasionally want to use its little brother, `sed`, which has substantially similar syntax. It is often the case in Unix programming that you have a pipe full of text data and you would like to transform every line of it; `sed` allows you to write these transforms into one line of instructions on the console line.

So it may sound crazy that you have all of these terse commands, but just imagine that you're trying to write a one-line program to reformat text documents and it suddenly makes a bit more sense.

Re: Actually using Ed

#10

    If you’re using any Unix at all, then ed really will always be there,
    no matter how old or limited the system.
So as it turns out, my Arch Linux setup does not actually have ed.
Post reply on HN