Neil Neil - 1 year ago 71
Linux Question

Linux: Output N Number of lines, starting from the End of a File

I want to output the last 3000 lines of a log file.

In other words: I do not want to print the first 3000 lines of the log file: Instead I want to print the last 3000 lines of a log file.

I know

prints out to the terminal screen the log file in its entirety in reverse order. But I do not want to print out the entire file. I looked at the available options and it appears that
cannot print out a certain number of lines.

Ultimately: I do not care if the last 3000 lines are printed out in ascending order or descending order: I just want to be able to see the last 3000 lines.


Answer Source

you can use:

tail -n 3000 | tac

if you want reverse order, otherwise, just

tail -n 3000
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download