HEAD(1) General Commands Manual HEAD(1)

headprint first part of files

head [-qvz] [-c size | -n num | -num] [file...]

head reads each file in sequence and writes it's first part on standard output. If no file is given, head reads from the standard input.

size
Read the first size bytes in each file.

size can be multiplied by one of KMGTP (Kilo, Mega, Giga, Tera, ...) using power of 1024 by default, which can be either explicit via adding iB (like MiB), or turned into powers of 1000 by adding B (like MB).

num, -num
Read the first num lines in each file.

The -num form is historical, new scripts should use the standard -n num form.

Don't print header when multiple file are given.
Always print header, regardless of the number of given file.
Use NULL as line delimiter, not newline.

If no option is specified, head defaults to reading the first 10 lines.

The head utility exits 0 on success, and >0 if an error occurs.

Contains the specified part of each file, with the following header when multiple file are given, or when -v is set:

"==> %s <==\n", <file>

head should be compliant with the IEEE Std 1003.1-2024 (“POSIX.1”) specification.
The -q, -v, and -z options are extensions. The -num option is historical.

Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>

2024-05-27 Linux 6.6.67-gentoo-x86_64