head [-n number][file...]
The head utility shall copy its input files to the standard output, ending the output for each file at a designated point.
Copying shall end at the point in each input file indicated by the -n number option. The option-argument number shall be counted in units of lines.
The head utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
The following option shall be supported:
When a file contains less than number lines, it shall be copied to standard output in its entirety. This shall not be an error.
If no options are specified, head shall act as if -n 10 had been specified.
The following operand shall be supported:
The standard input shall be used only if no file operands are specified. See the INPUT FILES section.
Input files shall be text files, but the line length is not restricted to {LINE_MAX} bytes.
The following environment variables shall affect the execution of head:
Default.
The standard output shall contain designated portions of the input files.
If multiple file operands are specified, head shall precede the output for each with the header:
"\n==> %s <==\n", <pathname>
except that the first header written shall not include the initial <newline>.
The standard error shall be used only for diagnostic messages.
None.
None.
The following exit values shall be returned:
Default.
The following sections are informative.
The obsolescent - number form is withdrawn in this version. Applications should use the -n number option.
To write the first ten lines of all files (except those with a leading period) in the directory:
head *
Although it is possible to simulate head with sed 10q for a single file, the standard developers decided that the popularity of head on historical BSD systems warranted its inclusion alongside tail.
This standard version of head follows the Utility Syntax Guidelines. The -n option was added to this new interface so that head and tail would be more logically related.
There is no -c option (as there is in tail) because it is not historical practice and because other utilities in this volume of IEEE Std 1003.1-2001 provide similar functionality.
None.
sed , tail