May 2013
Beginner to intermediate
384 pages
7h 40m
English
When looking into a large file, which consists of thousands of lines, we will not use a command such as cat to print the entire file contents. Instead we look for a sample (for example, the first 10 lines of the file or the last 10 lines of the file). We may need to print the first n lines or last n lines and even print all the lines except the last n lines or all lines except first n lines.
Another use case is to print lines from mth to nth lines.
The commands head and tail can help us do this.
The head command always reads the header portion of the input file.
$ head file
stdin as follows:
$ cat text | head
Read now
Unlock full access