2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document. The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
25 .\" This notice shall appear on any product containing this material.
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
43 .\" Copyright 1989 AT&T
44 .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved Portions
45 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
46 .\" Portions Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
47 .\" Portions Copyright (c) 2013, Joyent, Inc. All Rights Reserved
49 .TH HEAD 1 "Mar 4, 2013"
51 head \- display first few lines of files
56 \fB/usr/bin/head\fR [\fB-q\fR] [\fB-v\fR] [\fB-number\fR ] [ \fB-n\fR \fInumber\fR ] [ \fB-c\fR \fInumber\fR] [\fIfilename\fR]...
62 \fBhead\fR [\fB-qv\fR] [\fB-n\fR \fIlines\fR] [\fB-c\fR \fIchars\fR] [\fB-s\fR \fIskip\fR] [\fIfilename\fR]...
69 The \fBhead\fR utility copies the first \fInumber\fR of lines of each
70 \fIfilename\fR to the standard output. If no \fIfilename\fR is given,
71 \fBhead\fR copies lines from the standard input. The default value of
72 \fInumber\fR is \fB10\fR lines. If \fB-c\fR is specified, \fBhead\fR
73 copies the first \fInumber\fR of bytes of each filename.
76 When more than one file is specified, the start of each file looks like:
80 \fB==>\fR \fIfilename\fR \fB<==\fR
86 Thus, a common way to display a set of short files, identifying each one, is:
90 example% \fBhead -9999 filename1 filename2 ...\fR
98 The \fBhead\fR built-in in \fBksh93\fR is associated with the \fB/bin\fR and
99 \fB/usr/bin\fR paths. It is invoked when \fBhead\fR is executed without a
100 pathname prefix and the pathname search finds a \fB/bin/head\fR or
101 \fB/usr/bin/head\fR executable.
104 \fBhead\fR copies one or more input files to standard output, stopping at a
105 designated point for each file or to the end of the file whichever comes first.
106 Copying ends at the point indicated by the options. By default, a header of the
107 form \fB==> filename <==\fR is output before all but the first file but this
108 can be changed with the \fB-q\fR and \fB-v\fR options. If no file is given, or
109 if the file is \fB-\fR, \fBhead\fR copies from standard input starting at the
113 The option argument for \fB-c\fR and \fB-s\fR can optionally be followed by one
114 of the following characters to specify a different unit other than a single
145 For backwards compatibility, \fB-number\fR is equivalent to \fB-n\fR number.
150 The following options are supported by \fB/usr/bin/head\fR:
154 \fB\fB-n\fR \fInumber\fR\fR
157 The first \fInumber\fR lines of each input file is copied to standard output.
158 The \fInumber\fR option-argument must be a positive decimal integer.
164 \fB\fB-c\fR \fInumber\fR\fR
167 The first \fInumber\fR bytes of each input file is copied to standard output.
168 The \fInumber\fR option-argument must be a positive decimal integer. Note,
169 output may end in the middle of a character if a file contains multi-byte
176 \fB\fB-\fR\fInumber\fR\fR
179 The \fInumber\fR argument is a positive decimal integer with the same effect as
180 the \fB-n\fR \fInumber\fR option.
189 \fBhead\fR will not print a header in between each specified file.
198 \fBhead\fR will always print a header in between each specified file.
203 If no options are specified, \fBhead\fR acts as if \fB-n\fR \fB10\fR had been
208 The following options are supported by the head built-in command in
217 \fB\fB--lines=\fR\fIlines\fR\fR
220 Copy lines from each file. The default value is \fB10\fR.
230 \fB\fB--bytes=\fR\fIchars\fR\fR
233 Copy \fIchars\fR bytes from each file.
243 \fB\fB--quiet|silent\fR\fR
246 Never output filename headers.
256 \fB\fB--skip=\fR\fIskip\fR\fR
259 Skip \fIskip\fR characters or lines from each file before copying.
269 \fB\fB--verbose\fR\fR
272 Always output filename headers.
278 The following operand is supported:
282 \fB\fB\fIfilename\fR\fR\fR
285 A path name of an input file. If no \fIfile\fR operands are specified, the
286 standard input is used.
291 \fBExample 1 \fRWriting the First Ten Lines of All Files
294 The following example writes the first ten lines of all files, except those
295 with a leading period, in the directory:
300 example% \fBhead *\fR
305 .SH ENVIRONMENT VARIABLES
308 See \fBenviron\fR(5) for descriptions of the following environment variables
309 that affect the execution of \fBhead\fR: \fBLANG\fR, \fBLC_ALL\fR,
310 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
314 The following exit values are returned:
321 Successful completion.
336 See \fBattributes\fR(5) for descriptions of the following attributes:
345 ATTRIBUTE TYPE ATTRIBUTE VALUE
349 Interface Stability Committed
351 Standard See \fBstandards\fR(5).
362 ATTRIBUTE TYPE ATTRIBUTE VALUE
364 Interface Stability See below.
369 The \fBksh93\fR built-in binding to \fB/bin\fR and \fB/usr/bin\fR is Volatile.
370 The built-in interfaces are Uncommitted.
374 \fBcat\fR(1), \fBksh93\fR(1), \fBmore\fR(1), \fBpg\fR(1), \fBtail\fR(1),
375 \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)