NAME
head
—
extract file header
SYNOPSIS
head |
[-zqv ] [-n
[- ]lines]
[-c
[- ]bytes]
[file]… |
DESCRIPTION
Copies the first lines (default 10) or bytes of each file (the standard input stream if "-", the default) to the standard output stream.
With more than one file, each one is delineated by an empty line and
==> file
<==
If lines or
bytes start with a -
, all
but the last
lines or bytes of the
files are copied.
lines and bytes are in the mostly-case-insensitive format:
OPTIONS
-n
,--lines
=- Copy the first lines of each file. Default: 10.
-c
,--bytes
=- Copy the first bytes of each file.
-n
,--lines
=-
lines- Copy all but the last lines of each file.
-c
,--bytes
=-
bytes- Copy all but the last bytes of each file.
-z
,--zero-terminated
- Line separator is NUL, not newline. File headers are still written with newlines.
-q
,--quiet
,--silent
- Never write file headers.
-v
,--verbose
- Always write file headers.
EXIT STATUS
1 if a file couldn't be opened or read.
EXAMPLES
$
find
tests/-type f -executable -exec
head
-n
2{} +
==> tests/head <== #!/bin/sh # SPDX-License-Identifier: 0BSD ==> tests/env/test <== #!/bin/sh # SPDX-License-Identifier: 0BSD ==> tests/env/code/env.1-3c <== #!/usr/bin/env -S PYTHONUNBUFFERED=1 python3 -S echo "PYTHONUNBUFFERED=$PYTHONUNBUFFERED" # Strip signature generated by Linux sign-file$
head
-c
-
754/lib/modules/$(
uname
-r
)/updates/dkms/zfs.ko
SEE ALSO
STANDARDS
Conforms to IEEE Std 1003.1-2008
(“POSIX.1”); -czqv
,
"negative" and unit-suffixed lines and
bytes are extensions, originating from the GNU system.
-c
is also available under FreeBSD
4.0 and -qvc
under FreeBSD
3.0.
The GNU system disallows lines and bytes with B but without a multiplier and only supports integer bases.
A heretofore-unnoted legacy
-
lines argument format,
equivalent to -n
lines, is
also accepted, for compatibility with 1BSD. Avoid
it.
HISTORY
Appeared mostly fully-formed in 1BSD as head(VI):
4.3BSD-Reno fixes this, only allowing it as the first argument.
4.4BSD adds -n
lines and prunes
-
lines from the manual.
AT&T System V Release 4
UNIX sees 2BSD
head
.
IEEE Std 1003.2-1992
(“POSIX.2”) standardises both
lines forms, having created -n
to match tail
, but notes the
-
lines one as obsolescent.
It's removed in IEEE Std 1003.1-2001
(“POSIX.1”).