System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Trim logfile using i.e. sed.

 
Highlighted
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
Highlighted
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