'\" te .\" Copyright 1989 AT&T Copyright (c) 1995, Sun Microsystems, Inc. All Rights Reserved Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" 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 nl 1 "1995 年 3 月 28 日" "SunOS 5.11" "用户命令" .SH 名称 nl \- 行编号过滤器 .SH 用法概要 .LP .nf \fB/usr/bin/nl\fR [\fB-p\fR] [\fB-b\fR [\fItype\fR]] [\fB-d\fR [\fIdelim\fR]] [\fB-f\fR [\fItype\fR]] [\fB-h\fR [\fItype\fR]] [\fB-i\fR [\fIincr\fR]] [\fB-l\fR [\fInum\fR]] [\fB-n\fR [\fIformat\fR]] [\fB-s\fR [\fIsep\fR]] [\fB-w\fR [\fIwidth\fR]] [\fB-v\fR [\fIstartnum\fR]] [\fIfile\fR] .fi .LP .nf \fB/usr/xpg4/bin/nl\fR [\fB-p\fR] [\fB-b\fR \fItype\fR] [\fB-d\fR \fIdelim\fR] [\fB-f\fR \fItype\fR] [\fB-h\fR \fItype\fR] [\fB-i\fR \fIincr\fR] [\fB-l\fR \fInum\fR] [\fB-n\fR \fIformat\fR] [\fB-s\fR \fIsep\fR] [\fB-w\fR \fIwidth\fR] [\fB-v\fR \fIstartnum\fR] [\fIfile\fR] .fi .SH 描述 .sp .LP \fBnl\fR 实用程序读取指定的 \fIfile\fR 或标准输入(如果未指定 \fIfile\fR)中的行,并在标准输出中复制这些行。在左侧根据有效命令选项对行进行编号。 .sp .LP \fBnl\fR 按逻辑页查看其读取的文本。可在每个逻辑页的开头重置行编号。逻辑页由页眉、正文和页脚部分组成。空部分有效。页眉、正文和页脚可分别使用不同的行编号选项。例如,\fB-bt\fR(缺省值)会对正文部分的非空行进行编号,但不会对页眉和页脚部分的任何行编号。 .sp .LP 逻辑页部分开头将通过仅包含以下分隔符的输入行进行标记: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 行内容行首类型 _ \:\:\:页眉 _ \:\:正文 _ \:页脚 .TE .sp .LP 除非另有选择,否则 \fBnl\fR 假定正在读取的文本位于单个逻辑页正文中。 .SH 选项 .sp .LP 命令选项可以按任意顺序出现,并且可以与可选文件名组合使用。只能指定一个文件。当未在命令行上输入该选项时,将使用指定的缺省值。\fB/usr/xpg4/bin/nl\fR 选项需要选项参数。\fBSPACE\fR 字符\fB可以\fR 将选项与选项参数分隔开来。\fB/usr/bin/nl\fR 选项\fB可以\fR包含选项参数。如果没有为 \fB/usr/bin/nl\fR 选项指定选项参数,则这些选项将产生缺省值。支持的选项有: .sp .ne 2 .mk .na \fB\fB-b\fR\fItype\fR\fR .ad .RS 14n .rt 指定要进行编号的逻辑页正文行。识别的 \fItype\fR 及其含义如下: .sp .ne 2 .mk .na \fB\fBa\fR\fR .ad .RS 8n .rt 对所有行进行编号 .RE .sp .ne 2 .mk .na \fB\fBt\fR\fR .ad .RS 8n .rt 对所有非空行进行编号。 .RE .sp .ne 2 .mk .na \fB\fBn\fR\fR .ad .RS 8n .rt 不对任何行进行编号 .RE .sp .ne 2 .mk .na \fB\fBp\fIexp\fR\fR\fR .ad .RS 8n .rt 仅对包含 \fIexp\fR 中指定的正则表达式的行进行编号。请参见下文的“附注”部分。 .RE 逻辑页正文的缺省 \fItype\fR 为 \fBt\fR(对文本行进行编号)。 .RE .sp .ne 2 .mk .na \fB\fB-f\fR\fItype\fR\fR .ad .RS 14n .rt 与 \fB-b\fR\fItype\fR 相同(页脚除外)。逻辑页页脚的缺省 \fItype\fR 为 \fBn\fR(不对任何行进行编号)。 .RE .sp .ne 2 .mk .na \fB\fB-d\fR\fIdelim\fR\fR .ad .RS 14n .rt 可以将指定逻辑页部分开头的两个分隔符从缺省字符 (\ : ) 更改为用户指定的两个字符。如果仅输入一个字符,则第二个字符保持缺省字符 (:)。\fB-d\fR 与分隔符之间不应出现空格。要输入反斜杠,使用两个反斜杠。 .RE .sp .ne 2 .mk .na \fB\fB-h\fR\fItype\fR\fR .ad .RS 14n .rt 与 \fB-b\fR\fItype\fR相同(页眉除外)。逻辑页页眉的缺省 \fItype\fR 为 \fBn\fR(不对任何行进行编号)。 .RE .sp .ne 2 .mk .na \fB\fB-i\fR\fIincr\fR\fR .ad .RS 14n .rt \fIincr\fR 是指用于对逻辑页行进行编号的增量值。缺省 \fIincr\fR 为 \fB1\fR。 .RE .sp .ne 2 .mk .na \fB\fB-l\fR\fInum\fR\fR .ad .RS 14n .rt \fInum\fR 是指将被视为一行的空行数。例如,\fB-l2\fR 仅会对第二个相邻的空行进行编号(如果设置相应的 \fB-ha\fR、\fB-ba\fR 和/或 \fB-fa\fR 选项)。缺省 \fInum\fR 为 \fB1\fR。 .RE .sp .ne 2 .mk .na \fB\fB-n\fR\fIformat\fR\fR .ad .RS 14n .rt \fIformat\fR 是指行编号格式。识别的值包括: .sp .ne 2 .mk .na \fB\fBln\fR\fR .ad .RS 6n .rt 向左调整,禁止前导零 .RE .sp .ne 2 .mk .na \fB\fBrn\fR\fR .ad .RS 6n .rt 向右调整,禁止前导零 .RE .sp .ne 2 .mk .na \fB\fBrz\fR\fR .ad .RS 6n .rt 向右调整,保持前导零 .RE 缺省 \fIformat\fR 为 \fBrn\fR(向右调整)。 .RE .sp .ne 2 .mk .na \fB\fB-p\fR\fR .ad .RS 14n .rt 请勿在逻辑页分隔符处重新开始编号。 .RE .sp .ne 2 .mk .na \fB\fB-s\fR\fIsep\fR\fR .ad .RS 14n .rt \fIsep\fR 是指用于分隔行号与对应文本行的字符。缺省 \fIsep\fR 为\fB制表符\fR。 .RE .sp .ne 2 .mk .na \fB\fB-v\fR\fIstartnum\fR\fR .ad .RS 14n .rt \fIstartnum\fR 是指用于对逻辑页行进行编号的初始值。缺省 \fIstartnum\fR 为 \fB1\fR。 .RE .sp .ne 2 .mk .na \fB\fB-w\fR\fIwidth\fR\fR .ad .RS 14n .rt \fIwidth\fR 是指要用于行号的字符数。缺省 \fIwidth\fR 为 \fB6\fR。 .RE .SH 操作数 .sp .LP 支持下列操作数: .sp .ne 2 .mk .na \fB\fIfile\fR\fR .ad .RS 8n .rt 要编制行号的文本文件的路径名称。 .RE .SH 示例 .LP \fB示例 1 \fRnl 命令示例 .sp .LP 此命令: .sp .in +2 .nf example% \fBnl -v10 -i10 -d!+ filename1\fR .fi .in -2 .sp .sp .LP 将使逻辑页正文的第一行将被编号为 \fB10\fR、逻辑页正文的第二行将被编号为 \fB20\fR、第三行将被编号为 \fB30\fR,依此类推。逻辑页分隔符为 !+。 .SH 环境变量 .sp .LP 有关影响 \fBnl\fR 执行的以下环境变量的说明,请参见 \fBenviron\fR(5):\fBLANG\fR、\fBLC_ALL\fR、\fBLC_COLLATE\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 .ne 2 .mk .na \fB\fB/usr/lib/locale/\fIlocale\fR/LC_COLLATE/CollTable\fR\fR .ad .sp .6 .RS 4n 由 \fBlocaledef\fR 生成的整理表 .RE .sp .ne 2 .mk .na \fB\fB/usr/lib/locale/\fIlocale\fR/LC_COLLATE/coll.so\fR\fR .ad .sp .6 .RS 4n 包含字符串转换库例程的共享目标文件 .RE .SH 属性 .sp .LP 有关下列属性的说明,请参见 \fBattributes\fR(5): .SS "/usr/bin/nl" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/core-os .TE .SS "/usr/xpg4/bin/nl" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/xopen/xcu4 _ 接口稳定性Committed(已确定) _ 标准请参见 \fBstandards\fR(5)。 .TE .SH 另请参见 .sp .LP \fBpr\fR(1)、\fBattributes\fR(5)、\fBenviron\fR(5)、\fBregex\fR(5)、\fBregexp\fR(5)、\fBstandards\fR(5) .SH 附注 .sp .LP POSIX 和 "C" 语言环境中使用国际化正则表达式。在其他语言环境中,如果满足以下两个条件,则使用国际化正则表达式: .RS +4 .TP .ie t \(bu .el o 存在 \fB/usr/lib/locale/\fIlocale\fR/LC_COLLATE/CollTable\fR。 .RE .RS +4 .TP .ie t \(bu .el o 不存在 \fB/usr/lib/locale/\fIlocale\fR/LC_COLLATE/coll.so\fR。 .RE .sp .LP 否则,使用简单正则表达式。 .sp .LP \fBregex\fR(5) 对国际化正则表达式进行了说明。\fBregexp\fR(5) 对简单正则表达式进行了说明。