The head command will give you the first ten lines of a file or the first ten lines of the output of a command.
You can specify the number of lines that you want by using a hyphen followed by a number.
If there are not enough lines, you will get the whole output. No error is generated.
The tail command will display the last ten lines of a file or the last ten output lines of a command.
You can use a hyphen and a number to request a specific number of lines.
If there are not enough lines in the file, you will get the entire file. If you use a plus sign and a number, you will get all lines starting at the line number entered to the end of the file.
NOTE: The plus sign cannot be used with the head command, only with the tail command.
Head and Tail Commands Together
You can use head and tail together to gether a set of lines from a file or from the output of a command.
For example, if you want lines four through nine from num_file, you could type one of the following: