C Remove the first line from a text file without rewriting file
Posted
by Tom Van den Bon
on Stack Overflow
See other posts from Stack Overflow
or by Tom Van den Bon
Published on 2010-04-17T12:41:39Z
Indexed on
2010/04/17
12:43 UTC
Read the original article
Hit count: 205
Hi,
I've got a service which runs all the time and also keeps a log file. It basically adds new lines to the log file every few seconds. I'm written a small file which reads these lines and then parses them to various actions. The question I have is how can I delete the lines which I have already parsed from the log file without disrupting the writing of the log file by the service?
Usually when I need to delete a line in a file then I open the original one and a temporary one and then I just write all the lines to the temp file except the original which I want to delete. Obviously this method will not word here.
So how do I go about deleting them ?
© Stack Overflow or respective owner