Tuesday, January 29, 2013

How to TRIM a LOG



Trim a log file FIFO (First In - First Out).
sed -i -e :a -e '$q;N;<# lines to leave>,$D;ba' <mylogfile.log​>

In this example we'll leave the last 25,000 lines in the logfile and trim the older entries.
sed -i -e :a -e '$q;N;25000,$D;ba' mylogfile.log​

No comments:

Post a Comment