01-26-07 12:20 PM
tony <bigtoehere@hotmail.com> writes:
>Hi. A couple months ago I posted this question but didn't come up
>wuith a complete solution.
>
>"Can I use ex to find a pattern and NOT print that line and the
>previous x number of lines? "
>
>Several method of printing the previous lines were offerred but none
>were given to NOT print the previous 'x' number of lines.
>
>More details: I have a large text file (~70 megs). There are 'pages'
>in the file of 60 records each. The pattern I can search for is on
>the 60th line. There may be 1 or many pages in a row that I don't
>want.
I'll echo others in saying that ex is probably not the tool for the job,
for a number of reasons. Accepting this, then in the absence of unstated
confounding specs the task seems straightforward.
To not print the preceding x lines, simple delete them from the editor's
buffered copy of the database file before saving what's left to a new
file and then print that file. :-)
E.g., one by one look for a line containing "page n" and if that line
also contains the word "debit" delete that line and the preceding
60 lines. Print what's then left. Something like:
%g/page [0-9].*debit/-60;//d
w !lpr
q!
It might be wise to ensure your valuable text file is write protected
before letting any ex script loose on it.
--
John Savage (my news address is not valid for email)
[ Post a follow-up to this message ]
|