Current Article:

How to show first or last N lines of a file in Linux?

How to show first or last N lines of a file in Linux?

Type the following head command to display first 10 lines of a file named “file.txt”:

head -10 file.txt

And tail command will print last 20 lines of a file:

tail -20 file.txt