I am tailing a file. I want to remove lines from the file while I am tailing it. I'd like to avoid overwriting the file (truncating) and I would like to avoid replacing the file with a new file, because this most likely messes up / corrupts the tail command results.
Currently I have tried two different ways of doing this:
- Read the whole contents of the file, remove the unwanted lines of data, then write back to the file with less data than before. This results in some stderr spewed from the tail command => - "file was truncated"...- tail -Fis stilling working, but it does log this stderr.
- Use - sed -i '/pattern/d' my-file.txtto delete lines from the file that I no longer want. This results in some stderr spewed from the tail command =>- "file was replaced"(note different than above)...- tail -Fis still working, but it does log this stderr.
I am wondering if there is a way to delete lines from a file without truncating the file or replacing the file, as this seems to make life a little bit harder for tail than otherwise.
Should I just ignore this stderr? If I just ignore the stderr, I think the tail results will just be inaccurate. I need the tail results to be as accurate as possible because they are feeding into a new program, not being read by a human.
 
    