head Command - Output the Beginning of the Files

You can use the head command to output the beginning of the file. Use this when you want to check only the beginning of the file.

head FileName

The head command is fast because it doesn't read the entire file.

Head command sample

This is a sample head command that displays the beginning of foo.txt.

head foo.txt

Specify the number of lines to display at the beginning

You can specify the number of lines to display at the beginning by specifying the number of lines after the hyphen. The following example displays the first 20 lines.

head -20 filename

Associated Information