Read the last x lines of a log file

If like me you need to check out the PHP error log, but its bloody massive, you might want to take the last few lines of it.

tail -x log_file > new_log

That will take the last x number of lines from log_file and save into new_log

tail -10000 /var/log/httpd/error_log > ~/short_error_log

The above example will take the last 10,000 lines of the Apache error log, and save it into a new file ‘short_error_log’ in your home folder.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.