3 ms·
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 red
by cturner 14y ago
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.
- wglb 14y agoI do so as well. Most often it is sudo ed /etc/hosts.
- luriel 14y agoA Sam language tutorial by Rob Pike: http://doc.cat-v.org/bell_labs/sam_lang_tutorial/ 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 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).
- ralph 14y agoYes, I'm a user of ed regularly as well when I would like to mingle interacting with it with my other before and after command line use. If you use vim then `:set t_ti= t_te=' may be of interest to stop it switching to the terminal's other buffer and back; that way on exiting the file's content remains to copy-and-paste from. The article was OK. I'm not sure it mentioned addressing line 0 for the start of the file, and comma is more common than % for all lines. ed(1) is brief and lots can be learned from it. As for structural regular expressions as used in sam(1), see Rob Pike's paper. http://doc.cat-v.org/bell_labs/structural_regexps/ http://doc.cat-v.org/bell_labs/structural_regexps/
- drothlis 14y agoThanks for that link. 1987! Where's my structural-regexp-enabled awk!?