ed

dan%sri-tsc at sri-unix.UUCP dan%sri-tsc at sri-unix.UUCP
Wed Sep 28 02:14:00 AEST 1983


The Air Force Data Services Center modified the ed substitute command
to do just what you want (substitute on the n-th instance of a RE
in a line).  In the example you cited, the command would be:

	s5/i/i++/p

to substitute the fifth instance of "i" on the line to "i++".  If you put
a "g" on the end of the line it would substitute the 5th through the
last occurance on the line (which is a noop in this example).

They made lots of other nifty modifications to ed -- the best of which was
to allow you to just say "/string" when searching for "string" and save
the keystrokes of "/p".  Since 80% of what I do in ed is searching, that
turns out to be a big win.

I believe a copy of their code is on some of the earlier USENIX tapes
(three to five years ago).  It's v6 based, but would be worth converting
if you are a big ed fan.

	-Dan Chernikoff (dan at sri-tsc)



More information about the Comp.unix.wizards mailing list