SYNOPSIS
head
[
head
[
DESCRIPTION
By default, head displays the first 10 lines of each text file given on the command line. If you do not specify file, head reads the standard input.
Besides normal ASCII text files, head also works on
UTF-8 files and 16-bit wide Unicode files. Such files normally begin with
a multiple-byte marker indicating whether the file's contents are Unicode
big-endian, Unicode little-endian, or UTF-8. Such files are detected
automatically by head; however, when the multiple-byte
marker is missing you can use the
Normally, head's output format defaults to the format
of the first file it displays unless the
Options
-b num-
displays the first num x 512 characters of each file. With single byte characters, this is the first num blocks (a block is 512 bytes) of the file.
-c num-
displays the first num characters of each file.
-k num-
displays the first num x 1024 characters of each file. With single byte characters, this is the first num kilobytes of the file.
-l num-
displays the first num lines of each file.
-m num-
displays the first num x 1048576 (1024 x 1024) characters of each file. With single byte characters, this is the first num megabytes of the file.
-n num-
displays the first num lines of each file.
-U [[[c ][lb8oa ]][p [lb8oa ]]]-
specifies the input format of any file missing the initial multiple-byte marker, the output format produced, or both.
When
c is specified, the specifiers that follow it apply to the input consumed.When
p is specified, the specifiers that follow it apply to the output produced.When neither
c norp are specified, the remaining-U specifiers apply to the input consumed.When both
c andp are specified, the remaining-U arguments apply to both input and output.The remaining specifiers indicate the format of the characters read from input or written to output (as determined by
c andp ):l little-endian 16-bit wide charactersb big-endian 16-bit wide characters8 UTF-8 charactersa ASCII characters from the ANSI code pageo ASCII characters from the OEM code pageWhen multiple format specifiers can be associated with either c or p, the last appropriate one given on the command for each of c and p is used. For example:
-Ucoapl8 is the same as:
-Ucap8 When a p specifier is given without a c specifier and format specifiers are given before the p specifier, those format specifiers apply to the input. For example:
-Uopl is the same as:
-Ucopl When c or p is specified with no format specifies, little endian 16-bit wide characters are used by default for either input or output, as appropriate.
As an alternative to specifying formats for both input and output with the same
-U option, you can specify the-U option multiple times. For example, the following are identical:-Uca -Upb -Ucapb - Note:
-
The
-U specifiers are actually case-insensitive. For example, the following are all identical in their behavior:-Ucl -UcL -UCl -UCL
- num-
displays the first num lines of each file.
ENVIRONMENT VARIABLES
- TK_STDIO_DEFAULT_INPUT_FORMAT
-
Sets the default input format for files that don't have the initial multibyte marker. The value must be one of those listed in the File Character Formats section of the unicode reference page.
- TK_STDIO_DEFAULT_OUTPUT_FORMAT
-
Sets the default output format. Normally the format of the first file read is used as the default output format. The value must be one of those listed in the File Character Formats section of the unicode reference page.
DIAGNOSTICS
Possible exit status values are:
- 0
-
Successful completion.
- 1
-
Failure due to any of the following:
- 2
-
Failure due to any of the following:
- Badly formed line/byte count "num"
-
The value num, following a
-b ,-c ,-k ,-l ,-m , or-n option was not a valid number.
PORTABILITY
POSIX.2. x/OPEN Portability Guide 4.0. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022. Windows Server 2025.
The POSIX.2 standard only includes the
AVAILABILITY
PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
PTC MKS Toolkit 10.5 Documentation Build 40.