'\" te .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved Portions .\" Copyright 1989 AT&T .\" Portions Copyright (c) 2007, 2012, Oracle and/or its affiliates.All rights reserved. .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation.Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation.In the following statement, the phrase "this text" refers to portions of the system documentation.Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document.The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.This notice shall appear on any product containing this material. .TH head 1 "2012 年 1 月 21 日" "SunOS 5.11" "用户命令" .SH 名称 head \- 显示文件的前几行内容 .SH 用法概要 .LP .nf \fB/usr/bin/head\fR [\fB-number\fR | \fB-n\fR \fInumber\fR] [\fIfilename\fR]... .fi .SH 描述 .sp .LP \fBhead\fR 实用程序将每个 \fIfilename\fR 的前 \fInumber\fR 行内容复制到标准输出。未指定 \fIfilename\fR 时,\fBhead\fR 将从标准输入复制行。\fInumber\fR 的缺省值为 \fB10\fR 行。 .sp .LP 指定多个文件时,每个文件的开头类似于: .sp .in +2 .nf \fB==>\fR \fIfilename\fR \fB<==\fR .fi .in -2 .sp .LP 因此,要显示一组小文件的内容并标识各个文件,一种常用方法是: .sp .in +2 .nf example% \fBhead -9999 filename1 filename2 ...\fR .fi .in -2 .sp .SH 选项 .sp .LP 支持以下选项: .sp .ne 2 .mk .na \fB\fB-n\fR \fInumber\fR\fR .ad .RS 13n .rt 将每个输入文件的前 \fInumber\fR 行内容复制到标准输出。\fInumber\fR 选项参数必须是一个十进制正整数。 .RE .sp .ne 2 .mk .na \fB\fB-\fR\fInumber\fR\fR .ad .RS 13n .rt \fInumber\fR 参数是一个十进制正整数,与 \fB-n\fR \fInumber\fR 选项具有同等作用。 .RE .sp .LP 如果未指定选项,\fBhead\fR 在执行时会假定已指定了 \fB-n\fR \fB10\fR。 .SH 操作数 .sp .LP 支持下列操作数: .sp .ne 2 .mk .na \fB\fB\fIfilename\fR\fR\fR .ad .RS 12n .rt 输入文件的路径名称。如果未指定 \fIfile\fR 操作数,将使用标准输入。 .RE .SH 用法 .sp .LP 有关 \fBhead\fR 遇到大于或等于 2 GB(2^31 字节)文件时行为的说明,请参见 \fBlargefile\fR(5)。 .SH 示例 .LP \fB示例 1 \fR写入所有文件的前十行内容 .sp .LP 以下示例会写入目录中所有文件(带有前导句点的文件除外)的前十行内容: .sp .in +2 .nf example% \fBhead *\fR .fi .in -2 .sp .SH 环境变量 .sp .LP 有关影响 \fBhead\fR 执行的以下环境变量的说明,请参见 \fBenviron\fR(5):\fBLANG\fR、\fBLC_ALL\fR、\fBLC_CTYPE\fR、\fBLC_MESSAGES\fR 和 \fBNLSPATH\fR。 .SH 退出状态 .sp .LP 将返回以下退出值: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 6n .rt 成功完成。 .RE .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .RS 6n .rt 出现错误。 .RE .SH 属性 .sp .LP 有关下列属性的说明,请参见 \fBattributes\fR(5): .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/core-os _ CSIEnabled(已启用) _ 接口稳定性Committed(已确定) _ 标准请参见 \fBstandards\fR(5)。 .TE .SH 另请参见 .sp .LP \fBcat\fR(1)、\fBmore\fR(1)、\fBpg\fR(1)、\fBtail\fR(1)、\fBattributes\fR(5)、\fBenviron\fR(5)、\fBlargefile\fR(5)、\fBstandards\fR(5)