1HEAD(1P)                   POSIX Programmer's Manual                  HEAD(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       head - copy the first part of files
13

SYNOPSIS

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

DESCRIPTION

18       The head utility shall copy its input files  to  the  standard  output,
19       ending the output for each file at a designated point.
20
21       Copying  shall  end at the point in each input file indicated by the -n
22       number option. The option-argument number shall be counted in units  of
23       lines.
24

OPTIONS

26       The  head  utility  shall  conform  to  the  Base Definitions volume of
27       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
28
29       The following option shall be supported:
30
31       -n  number
32              The first number lines of each input file  shall  be  copied  to
33              standard  output.  The  application shall ensure that the number
34              option-argument is a positive decimal integer.
35
36
37       When a file contains less than number lines,  it  shall  be  copied  to
38       standard output in its entirety. This shall not be an error.
39
40       If no options are specified, head shall act as if -n 10 had been speci‐
41       fied.
42

OPERANDS

44       The following operand shall be supported:
45
46       file   A pathname of an input file. If no file operands are  specified,
47              the standard input shall be used.
48
49

STDIN

51       The  standard  input  shall be used only if no file operands are speci‐
52       fied. See the INPUT FILES section.
53

INPUT FILES

55       Input files shall be text files, but the line length is not  restricted
56       to {LINE_MAX} bytes.
57

ENVIRONMENT VARIABLES

59       The following environment variables shall affect the execution of head:
60
61       LANG   Provide  a  default value for the internationalization variables
62              that are unset or null. (See  the  Base  Definitions  volume  of
63              IEEE Std 1003.1-2001,  Section  8.2,  Internationalization Vari‐
64              ables for the precedence of internationalization variables  used
65              to determine the values of locale categories.)
66
67       LC_ALL If  set  to a non-empty string value, override the values of all
68              the other internationalization variables.
69
70       LC_CTYPE
71              Determine the locale for  the  interpretation  of  sequences  of
72              bytes  of  text  data as characters (for example, single-byte as
73              opposed to multi-byte characters in arguments and input files).
74
75       LC_MESSAGES
76              Determine the locale that should be used to  affect  the  format
77              and contents of diagnostic messages written to standard error.
78
79       NLSPATH
80              Determine the location of message catalogs for the processing of
81              LC_MESSAGES .
82
83

ASYNCHRONOUS EVENTS

85       Default.
86

STDOUT

88       The standard output shall contain  designated  portions  of  the  input
89       files.
90
91       If  multiple file operands are specified, head shall precede the output
92       for each with the header:
93
94
95              "\n==> %s <==\n", <pathname>
96
97       except that the first header written  shall  not  include  the  initial
98       <newline>.
99

STDERR

101       The standard error shall be used only for diagnostic messages.
102

OUTPUT FILES

104       None.
105

EXTENDED DESCRIPTION

107       None.
108

EXIT STATUS

110       The following exit values shall be returned:
111
112        0     Successful completion.
113
114       >0     An error occurred.
115
116

CONSEQUENCES OF ERRORS

118       Default.
119
120       The following sections are informative.
121

APPLICATION USAGE

123       The  obsolescent  - number form is withdrawn in this version.  Applica‐
124       tions should use the -n number option.
125

EXAMPLES

127       To write the first ten lines of all files (except those with a  leading
128       period) in the directory:
129
130
131              head *
132

RATIONALE

134       Although  it  is  possible  to  simulate head with sed 10q for a single
135       file, the standard developers decided that the popularity  of  head  on
136       historical BSD systems warranted its inclusion alongside tail.
137
138       This  standard  version  of head follows the Utility Syntax Guidelines.
139       The -n option was added to this new interface so  that  head  and  tail
140       would be more logically related.
141
142       There  is no -c option (as there is in tail) because it is not histori‐
143       cal  practice  and  because  other  utilities   in   this   volume   of
144       IEEE Std 1003.1-2001 provide similar functionality.
145

FUTURE DIRECTIONS

147       None.
148

SEE ALSO

150       sed, tail
151
153       Portions  of  this text are reprinted and reproduced in electronic form
154       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
155       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
156       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
157       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
158       event of any discrepancy between this version and the original IEEE and
159       The  Open Group Standard, the original IEEE and The Open Group Standard
160       is the referee document. The original Standard can be  obtained  online
161       at http://www.opengroup.org/unix/online.html .
162
163
164
165IEEE/The Open Group                  2003                             HEAD(1P)
Impressum