Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!tektronix!ogcvax!omsvax!hplabs!sri-unix!dan@sri-tsc From: dan%sri-tsc@sri-unix.UUCP Newsgroups: net.unix-wizards Subject: Re: ed Message-ID: <12083@sri-arpa.UUCP> Date: Tue, 27-Sep-83 12:14:00 EDT Article-I.D.: sri-arpa.12083 Posted: Tue Sep 27 12:14:00 1983 Date-Received: Fri, 30-Sep-83 02:02:37 EDT Lines: 20 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@sri-tsc)