Linux: Head, Tail

By Xah Lee. Date: .

Show first n lines

head filename
Show first n lines of a file. (most useful for big files, e.g. Log file.)
head -n 100 filename
Show first 100 lines of a file.

Show last n lines

tail filename
Show the last n lines of a file.
head -n 100 filename
Show last 100 lines of a file.
tail -f fname
View the last few lines of a growing file, updated continuously. Typically used on log files. Ctrl+c to exit.

Linux, Process Text