HOME

TheInfoList



OR:

nl is a Unix utility for numbering lines, either from a file or from standard input, reproducing output on standard output.


History

is part of the
X/Open X/Open group (also known as the Open Group for Unix Systems and incorporated in 1987 as X/Open Company, Ltd.) was a consortium founded by several European UNIX systems manufacturers in 1984 to identify and promote open standards in the field of in ...
Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and the Single Unix Specification. It first appeared in
System V Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
release 2. The version of nl bundled in
GNU GNU () is an extensive collection of free software Free software or libre software is computer software distributed under terms that allow users to run the software for any purpose as well as to study, change, and distribute it and any ...
coreutils The GNU Core Utilities or coreutils is a package of GNU software containing implementations for many of the basic tools, such as cat, ls, and rm, which are used on Unix-like operating systems. In September 2002, the ''GNU coreutils'' were c ...
was written by Scott Bartram and David MacKenzie. The command is available as a separate package for Microsoft Windows as part of the
UnxUtils UnxUtils is a collection of ports of common GNU Unix-like utilities to native Win32, with executables only depending on the Microsoft C- runtime msvcrt.dll. The collection was last updated externally on April 15, 2003, by Karl M. Syring. ...
collection of
native Native may refer to: People * Jus soli, citizenship by right of birth * Indigenous peoples, peoples with a set of specific rights based on their historical ties to a particular territory ** Native Americans (disambiguation) In arts and enterta ...
Win32 The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. The name Windows API collectively refers to several different platform implementations ...
ports A port is a maritime facility comprising one or more wharves or loading areas, where ships load and discharge cargo and passengers. Although usually situated on a sea coast or estuary, ports can also be found far inland, such as Ha ...
of common GNU Unix-like utilities.


Syntax

The command has a number of switches: *a - number all lines *t - number lines with printable text only *n - no line numbering *string - number only those lines containing the regular expression defined in the ''string'' supplied. The default applied switch is ''t''. nl also supports some command line options.


Example

$ nl tf 1 echo press cr 2 read cr 3 done The following example numbers only the lines that begin with a capital letter A (matching on the
regular expression A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
/^A/). ''filename'' is optional. $ nl -b p^A filename apple 1 Apple BANANA 2 Allspice strawberry It can be useful as an alternative to : $ cat somefile aaaa bbbb cccc dddc $ nl somefile , grep cccc 3 cccc


See also

*
wc (Unix) (short for word count) is a command in Unix, Plan 9, Inferno, and Unix-like operating systems. The program reads either standard input or a list of computer files and generates one or more of the following statistics: newline count, word count, ...
– the word count command *
cat (Unix) cat is a standard Unix utility that reads files sequentially, writing them to standard output. The name is derived from its function to (con)catenate files (from Latin ''catenare'', "to chain"). It has been ported to a number of operating syst ...
– concatenate command (-n flag is equivalent to nl -a) *
List of Unix commands This is a list of Unix commands as specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification (SUS). These commands can be found on Unix operating systems and most Unix-like operating systems. List See also * List of G ...


References


External links

{{Core Utilities commands Unix text processing utilities Unix SUS2008 utilities