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.
The syntax is as follows:
head [OPTION] [FILE …]
head prints first 10 lines of each FILE to