Copy the first part of files (POSIX)


head [-l] [-number] [-c number] [-n number] [file]...

Runs on:

QNX Neutrino, Microsoft Windows


Deprecated; use -n number instead.
-c number
(QNX Neutrino extension) The number of bytes to copy. The number argument is an unsigned decimal integer.
("el"; QNX Neutrino extension) Measure the quantity of output in lines; this is the default unit of measure.
-n number
The number of lines to copy. The number argument is an unsigned decimal integer.
The pathname of an input file. If you don't specify any files, the standard input is used.


The head utility copies its input files to the standard output. The utility ends the output for each file at a point designated by the -c or -n option. If you don't specify either of these options, head copies the first ten lines of the file.

If you specify multiple -c, -l, and -n options, the last one takes precedence.

If you specify multiple files, head prints an identifying header before the output for each file.


Display the first ten lines of all files in the current directory:

head *

Print the first 16 bytes of myfile in hex:

head -c 16 myfile | hd

(Note that in this case, the same functionality is offered through command-line options to hd.)

Exit status:

Successful completion.
An error occurred.