'\" te .\" Copyright (c) 2009, 2011, Oracle and/or its affiliates.All rights reserved. .\" Copyright 1989 AT&T .\" Copyright (c) 1992, X/Open Company Limited 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 tail 1 "2011 年 7 月 28 日" "SunOS 5.11" "用户命令" .SH 名称 tail \- 提供文件的最后部分 .SH 用法概要 .LP .nf \fB/usr/bin/tail\fR [±s \fInumber\fR [lbcr]] [\fIfile\fR] .fi .LP .nf \fB/usr/bin/tail\fR [\fB-lbcr\fR] [\fIfile\fR] .fi .LP .nf \fB/usr/bin/tail\fR [± \fInumber\fR [lbcf]] [\fIfile\fR] .fi .LP .nf \fB/usr/bin/tail\fR [\fB-lbcf\fR] [\fIfile\fR] .fi .LP .nf \fB/usr/xpg4/bin/tail\fR [\fB-f\fR | \fB-r\fR] [\fB-c\fR \fInumber\fR | \fB-n\fR \fInumber\fR] [\fIfile\fR] .fi .LP .nf \fB/usr/xpg4/bin/tail\fR [± \fInumber\fR [l | b | c] [f]] [\fIfile\fR] .fi .LP .nf \fB/usr/xpg4/bin/tail\fR [± \fInumber\fR [l] [f | r]] [\fIfile\fR] .fi .SH 描述 .sp .LP \fBtail\fR 实用程序将已命名的文件复制到标准输出中指定位置的开始处。如果未命名任何文件,则使用标准输入。 .sp .LP 从文件中由 \fB-c\fR \fInumber\fR、\fB-n\fR \fInumber\fR 或 \fB±\fR \fInumber\fR 选项指示的位置开始复制(如果指定 \fB+\fR \fInumber\fR,则从开头的某位置开始;如果指定 \fB-\fR \fInumber\fR,则从输入结束位置开始;如果 \fInumber\fR 为 \fINULL\fR,则假定值为 \fB10\fR)。\fInumber\fR 将根据 \fB-c\fR 或 \fB-n\fR 选项或行、块或字节以行或字节为单位进行计数,具体取决于附加选项 \fBl\fR、\fBb\fR 或 \fBc\fR。如果未指定单位,则按行进行计数。 .SH 选项 .sp .LP \fB/usr/bin/tail\fR 和 \fB/usr/xpg4/bin/tail\fR 支持以下选项。\fB-r\fR 和 \fB-f\fR 选项互斥。如果在命令行中同时指定这两个选项,则忽略 \fB-f\fR 选项。 .sp .ne 2 .mk .na \fB\fB-b\fR\fR .ad .RS 6n .rt 以块为单位。 .RE .sp .ne 2 .mk .na \fB\fB-c\fR\fR .ad .RS 6n .rt 以字节为单位。 .RE .sp .ne 2 .mk .na \fB\fB-f\fR\fR .ad .RS 6n .rt 跟随。如果输入文件不是管道文件,则在已复制完输入文件的行之后,该程序不会终止,但会陷入无限循环,从中它会休眠一秒钟,然后尝试读取和复制输入文件的后续记录。因此,它可用于监视某些其他进程写入的文件的增长情况。 .RE .sp .ne 2 .mk .na \fB\fB-l\fR\fR .ad .RS 6n .rt 以行为单位。 .RE .sp .ne 2 .mk .na \fB\fB-r\fR\fR .ad .RS 6n .rt 反序。从文件的指定开始位置以反序复制行。\fBr\fR 的缺省行为是以反序打印整个文件。 .RE .SS "/usr/xpg4/bin/tail" .sp .LP \fB/usr/xpg4/bin/tail\fR 仅支持以下选项: .sp .ne 2 .mk .na \fB\fB-c\fR \fInumber\fR\fR .ad .RS 13n .rt \fInumber\fR 选项参数必须为十进制整数,其符号会影响在文件中开始复制的位置,以字节为度量标准。 .sp .ne 2 .mk .na \fB\fB+\fR\fR .ad .RS 8n .rt 从文件的相对开始位置开始复制。 .RE .sp .ne 2 .mk .na \fB\fB-\fR\fR .ad .RS 8n .rt 从文件的相对结束位置开始复制。 .RE .sp .ne 2 .mk .na \fBnone\fR .ad .RS 8n .rt 从文件的相对结束位置开始复制。 .RE 计数的最初值为 1;即,\fB\fR\fB-c\fR \fB+1\fR 表示文件的第一个字节,\fB\fR\fB-c\fR \fB-1\fR 表示文件的最后一个字节。 .RE .sp .ne 2 .mk .na \fB\fB-n\fR \fInumber\fR\fR .ad .RS 13n .rt 除在文件中的开始位置以行而不是字节为度量标准外,与 \fB-c\fR \fInumber\fR 相同。计数的初始值为 \fB1\fR。即,\fB-n\fR \fB+1\fR 表示文件的第一行,\fB-n\fR \fB-1\fR 表示文件的最后一行。 .RE .SH 操作数 .sp .LP 支持下列操作数: .sp .ne 2 .mk .na \fB\fIfile\fR\fR .ad .RS 8n .rt 输入文件的路径名称。如果未指定 \fIfile\fR 操作数,将使用标准输入。 .RE .SH 用法 .sp .LP 有关 \fBtail\fR 遇到大于或等于 2 GB(2^31 字节)文件时行为的说明,请参见 \fBlargefile\fR(5)。 .SH 示例 .LP \fB示例 1 \fR使用 tail 命令 .sp .LP 以下命令打印文件 \fBfred\fR 的最后十行,后跟从启动 \fBtail\fR 到将其终止这段时间内附加到 \fBfred\fR 的所有行。 .sp .in +2 .nf example% \fBtail -f fred\fR .fi .in -2 .sp .sp .LP 下一个命令打印文件 \fBfred\fR 的最后 15 个字节,后跟从启动 \fBtail\fR 到将其终止这段时间内附加到 \fBfred\fR 的所有行。 .sp .in +2 .nf example% \fBtail -15cf fred\fR .fi .in -2 .sp .SH 环境变量 .sp .LP 有关影响 \fBtail\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): .SS "/usr/bin/tail" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/core-os _ CSIEnabled(已启用) .TE .SS "/usr/xpg4/bin/tail" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/xopen/xcu4 _ CSIEnabled(已启用) _ 接口稳定性Committed(已确定) _ 标准请参见 \fBstandards\fR(5)。 .TE .SH 另请参见 .sp .LP \fBcat\fR(1)、\fBhead\fR(1)、\fBmore\fR(1)、\fBpg\fR(1)、\fBdd\fR(1M)、\fBattributes\fR(5)、\fBenviron\fR(5)、\fBlargefile\fR(5)、\fBstandards\fR(5) .SH 附注 .sp .LP 相对于文件结束位置的管道文件尾部存储在缓冲区,因此其长度受限。在字符特殊文件中可发生各种异常行为。