xref: /titanic_50/usr/src/man/man1/nl.1 (revision d583b39bfb4e2571d3e41097c5c357ffe353ad45)
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.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
NL 1 "Mar 28, 1995"
NAME
nl - line numbering filter
SYNOPSIS

/usr/bin/nl [-p] [-b [type]] [-d [delim]] [-f [type]]
 [-h [type]] [-i [incr]] [-l [num]] [-n [format]]
 [-s [sep]] [-w [width]] [-v [startnum]] [file]

/usr/xpg4/bin/nl [-p] [-b type] [-d delim] [-f type]
 [-h type] [-i incr] [-l num] [-n format] [-s sep]
 [-w width] [-v startnum] [file]
DESCRIPTION

The nl utility reads lines from the named file, or the standard input if no file is named, and reproduces the lines on the standard output. Lines are numbered on the left in accordance with the command options in effect.

nl views the text it reads in terms of logical pages. Line numbering is reset at the start of each logical page. A logical page consists of a header, a body, and a footer section. Empty sections are valid. Different line numbering options are independently available for header, body, and footer. For example, -bt (the default) numbers non-blank lines in the body section and does not number any lines in the header and footer sections.

The start of logical page sections are signaled by input lines containing nothing but the following delimiter character(s):

Line contents Start Of
\e:\e:\e: header
\e:\e: body
\e: footer

Unless optioned otherwise, nl assumes the text being read is in a single logical page body.

OPTIONS

Command options may appear in any order and may be intermingled with an optional file name. Only one file may be named. The specified default is used when the option is not entered on the command line. /usr/xpg4/bin/nl options require option arguments. A SPACE character may separate options from option arguments. /usr/bin/nl options may have option arguments. If option-arguments of /usr/bin/nl options are not specified, these options result in the default. The supported options are: -btype

Specifies which logical page body lines are to be numbered. Recognized types and their meanings are: a

number all lines

t

number all non-empty lines.

n

no line numbering

pexp

number only lines that contain the regular expression specified in exp. See NOTES below.

Default type for logical page body is t (text lines numbered).
-ftype

Same as -btype except for footer. Default type for logical page footer is n (no lines numbered).

-ddelim

The two delimiter characters specifying the start of a logical page section may be changed from the default characters (\e\|:\|) to two user-specified characters. If only one character is entered, the second character remains the default character (:). No space should appear between the -d and the delimiter characters. To enter a backslash, use two backslashes.

-htype

Same as -btype except for header. Default type for logical page header is n (no lines numbered).

-iincr

incr is the increment value used to number logical page lines. Default incr is 1.

-lnum

num is the number of blank lines to be considered as one. For example, -l2 results in only the second adjacent blank being numbered (if the appropriate -ha, -ba, and/or -fa option is set). Default num is 1.

-nformat

format is the line numbering format. Recognized values are: ln

left justified, leading zeroes suppressed

rn

right justified, leading zeroes suppressed

rz

right justified, leading zeroes kept

Default format is rn (right justified).
-p

Do not restart numbering at logical page delimiters.

-ssep

sep is the character(s) used in separating the line number and the corresponding text line. Default sep is a TAB.

-vstartnum

startnum is the initial value used to number logical page lines. Default startnum is 1.

-wwidth

width is the number of characters to be used for the line number. Default width is 6.

OPERANDS

The following operand is supported: file

A path name of a text file to be line-numbered.

EXAMPLES

Example 1 An example of the nl command

The command:

example% nl -v10 -i10 -d!+ filename1

will cause the first line of the page body to be numbered 10, the second line of the page body to be numbered 20, the third 30, and so forth. The logical page delimiters are !+.

ENVIRONMENT VARIABLES

See environ(5) for descriptions of the following environment variables that affect the execution of nl: LANG, LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES, and NLSPATH.

EXIT STATUS

The following exit values are returned: 0

Successful completion.

>0

An error occurred.

FILES
/usr/lib/locale/locale/LC_COLLATE/CollTable

Collation table generated by localedef

/usr/lib/locale/locale/LC_COLLATE/coll.so

Shared object containing string transformation library routines

ATTRIBUTES

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Standard
SEE ALSO

pr(1), attributes(5), environ(5), regex(5), regexp(5), standards(5)

NOTES

Internationalized Regular Expressions are used in the POSIX and "C" locales. In other locales, Internationalized Regular Expressions are used if the following two conditions are met:

/usr/lib/locale/locale/LC_COLLATE/CollTable is present.

/usr/lib/locale/locale/LC_COLLATE/coll.so is not present.

Otherwise, Simple Regular Expressions are used.

Internationalized Regular Expressions are explained on regex(5). Simple Regular Expressions are explained on regexp(5).