Using Linux ‘head’ command to preview a file

This article will show you how to use the head command in Linux. head is used to print out the beginning of a file. For example, this is useful when you have a giant text file and you want to preview the contents without attempting to open the entire file. Here are some common examples on the usage:

Examples of ‘head’ command

To print out the first 10 lines of a file
head [filename]

To print out the first 50 lines of a file
head -n 50 [filename]

To print out the first 25 bytes of a file
head -c 25 [filename]


Please post your comments/suggestions!