Name

head

Synopsis

    head [options] [files]

Print the first few lines of one or more files (default is 10).

Common Options

- n

Print the first n lines of the file. This is traditional head behavior, although it is not blessed by all versions of the POSIX standard.

-n n

Print the first n lines of the file.

GNU/Linux Options

-cnum[b|k|m], --bytesnum[b|k|m]

Print first num bytes or, if num is followed by b, k, or m, first num 512-byte blocks, 1-kilobyte blocks, or 1-megabyte blocks.

--lines num

Same as -n.

-q, --quiet, --silent

Quiet mode; never print headers giving filenames.

-v, --verbose

Print filename headers, even for only one file.

Examples

Display the first 20 lines of phone_list :

    head -n 20 phone_list

Display the first 10 phone numbers having a 202 area code:

    grep '(202)' phone_list | head

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.