The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

head - copy the first part of files

 SYNOPSIS



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

head [number][file...]

 DESCRIPTION

The head utility will copy its input files to the standard output, ending the output for each file at a designated point.

Copying will end at the point in each input file indicated by the -n number option (or the -number argument). The option-argument number will be counted in units of lines.

 OPTIONS

The head utility supports the XBD specification, Utility Syntax Guidelines  , except that the obsolescent version accepts multi-character numeric options.

The following options are supported:

-n number
The first number lines of each input file will be copied to standard output. The number option-argument must be a positive decimal integer.
-number
The number argument is a positive decimal integer with the same effect as the -n number option.

If no options are specified, head will act as if -n 10 had been specified.

 OPERANDS

The following operand is supported:
file
A pathname of an input file. If no file operands are specified, the standard input will be used.

 STDIN

The standard input will be used only if no file operands are specified. See the INPUT FILES section.

 INPUT FILES

Input files must be text files, but the line length is not restricted to {LINE_MAX} bytes.

 ENVIRONMENT VARIABLES

The following environment variables affect the execution of head:
LANG
Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
LC_ALL
If set to a non-empty string value, override the values of all the other internationalisation variables.
LC_CTYPE
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files).
LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
NLSPATH
Determine the location of message catalogues for the processing of LC_MESSAGES .

 ASYNCHRONOUS EVENTS

Default.

 STDOUT

The standard output will contain designated portions of the input files.

If multiple file operands are specified, head will precede the output for each with the header:

"\n==> %s <==\n", <pathname> except that the first header written will not include the initial newline character.

 STDERR

Used only for diagnostic messages.

 OUTPUT FILES

None.

 EXTENDED DESCRIPTION

None.

 EXIT STATUS

The following exit values are returned:
0
Successful completion.
>0
An error occurred.

 CONSEQUENCES OF ERRORS

Default.

 APPLICATION USAGE

None.

 EXAMPLES

To write the first ten lines of all files (except those with a leading period) in the directory:

head *

 FUTURE DIRECTIONS

The obsolescent -number form may be withdrawn in a future issue. Applications should use the -n number option.

 SEE ALSO

sed, tail.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]