Neil Neil - 17 days ago 4x
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.



you can use:

tail -n 3000 | tac

if you want reverse order, otherwise, just

tail -n 3000