yes, it's very possible. you might want to consider other methods. i have one idea, but it assumes two things (though it might be adaptable to other environments):
- unix-like system
- you know where those appends are coming from
my suggested alternate plan is this:
- move the file (`mv flat.file flat.file.tmp`)
- HUP any process that might still have the file open for writing, or wait until thy die themselves (see below)
- read and delete the temporary version
as i said, it relies on you knowing what might write to that file. if those programs open and write and re-close the file, then you can just wait the maimum time it might make one of them to finish. if they keep it open, however, you'll want to HUP them or otherwise force a close-reopen cycle. this sounds extreme, i know, but it's safe in more circumstances than you might think, for example, apache servers.
the reason this works at all is tha tif you move a file that another process already has open, the other process won't notice, and ill keep writing to it without a problem.
the problem, really, is that unix doesn't provide you with any way to delete from teh front of a file. maybe some day there will be an OS without that problem.
.