This thread seems to have spread to numerous additional newsgroups
since I first contributed to it. Must be a gripping topic? :-)
Getting back to the original request, viz., that of using ed to perform
the required numbering, it seems that only one invocation is needed:
ed - textfile > ftmp <<\+
This writes the line numbers to a temporary file then reads them back.
A pecularity of the g function seems to be that ed echoes to standard
output the lines that are matched. In this scheme these are unavoidably
going to be appended to the temporary file, so I've arranged that it's
the line numbers that are echoed rather than the lines of data so that
the amount of unwanted text being written is kept to a minimum. A file
residing in ram would be ideal, as /tmp sometimes is.
BTW other posters have alluded to ed solutions having been posted here
but (apart from that nightmarish-looking scheme) I've seen none and this
I attribute not to a flaky newsfeed but rather a *partial* newsfeed. :-(
And I've eschewed the n function, it being unavailable in older versions.
John Savage koala ~ sydney.dialix.com.au <-- use this address