Deleting processed lines

I have a log file that I am processing. This contains messages from and to a server (requests and responses).
The responses to requests may not be in order i.e. we can have a response to a request after several requests are sent, and in some error cases there may not be any response message.

The log file is usually 2MB+ in size, so I am trying to see if there is a way I can find a request message and its response and after I find this delete it from the logfile and again start at the beginning of the logfile for the next request / response message.

Is there a way to delete the lines from the file OR can anyone suggest a better way to go about this?

Hi,

if you want to search some pattern and delete the whole matching line then you can use like below..

sed '/pattern/d' filename.log

if you want to search pattern only then ..

sed '/pattern/p' filename.log

Thanks
Sha

Best post example lines or an excerpt of the log and the wanted output. Use the [ code ] tags BBCode - Wikipedia, the free encyclopedia of the forum if you do so.