On Thu, Mar 26, 2020 at 07:59:38AM -0700, Joe Clark wrote:
> I am looking for a way to periodically remove the first N lines of a file,
> to implement a "quick and dirty" log file size management scheme.
>
> I have found that vi will effectively do this, and (somewhat surprisingly)
> the logging
The problem with using tail, sed, or similar is that they use intermediate
files. For the use case I'm describing, I need to be modifying the SAME
file (same inode), because I'm trying to change a "live" file that the
other process is writing to. Living dangerously, I know.
On Thu, Mar 26, 2020
Yes, I think tail is a much simpler option. Just be aware you can't do
this:
tail -n 25 myfile > myfile
... because the "> myfile" opens and truncates the file (throwing away the
contents) before the tail command runs.
Something like this would work:
tail -n 25 myfile > /tmp/tail$$
mv /tmp/t
> I am looking for a way to periodically remove the first N lines of a file,
> to implement a "quick and dirty" log file size management scheme.
>
Have you looked at tail and its options? sed would probably also work, but
tail is probably more obvious.
--
--
You received this message from the "v
I am looking for a way to periodically remove the first N lines of a file,
to implement a "quick and dirty" log file size management scheme.
I have found that vi will effectively do this, and (somewhat surprisingly)
the logging application seems to be okay with its log file being modified.
I ha