To display the content of a file, we will use the
cat command. The
cat command displays the whole file content on
stdout. However, sometimes, we are interested in viewing only a few lines of a file. In this case, using
cat will be tedious because we will have to scroll down to particular lines that we are interested in.
Shell provides us the
tail commands to print only the lines in which we are interested in. The main difference between both the commands is,
head prints the lines from the beginning of the files, and tail prints the lines from the end of the files.
head [OPTION] [FILE …]
head prints first 10 lines of each FILE to
stdout. If no file is mentioned or '
-' is specified, the input is taken from
The options available in head can be used to change how much of the content to be printed. The options available are described in the following table: