http://www.perlmonks.org?node_id=469129


in reply to Re: removing lines from a file
in thread removing lines from a file

You have some alternatives for this task, but have to see this points:
- will the log file be rotated?
- can the application is writing the log write to a fifo?

If you do the fifo alternative, be careful to some log rotate application DO NOT rotate the fifo. Using the fifo you can easily dismiss the lines you don't want to store. If the application can output to STDOUT, you can redirect STDOUT to SDERR and read it (as STDIN is buffered) and then dismiss all lines you don't bother.