Operating System - Linux
1753404 Members
7427 Online
108793 Solutions
New Discussion

Trim logfile using i.e. sed.

 
Joakim Brosten
Frequent Advisor

Trim logfile using i.e. sed.

Hi,

I want to delete all lines but the last 500 in a text log file . At the time of deletion, the number of lines will vary.

/Joakim
1 REPLY 1
Oviwan
Honored Contributor

Re: Trim logfile using i.e. sed.

hy

with tail you can get the last 500 lines:

tail -500 logfile

so you could always redirect the last 500 lines:

tail -500 logfile >last500.log

regards