Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

nl (Unix)

From Wikipedia, the free encyclopedia
Unix command
nl
Operating systemUnix andUnix-like
PlatformCross-platform
TypeCommand
Licensecoreutils:GPLv3+

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

History

[edit]

nl is part of theX/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and theSingle Unix Specification.[1] It first appeared inSystem V release 2.[2]

The version ofnl bundled inGNUcoreutils was written by Scott Bartram and David MacKenzie.[3]

The command is available as a separate package forMicrosoft Windows as part of theUnxUtils collection ofnativeWin32ports of common GNU Unix-like utilities.[4]

Syntax

[edit]

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 thestring supplied.

The default applied switch ist.

nl also supports some command line options.

Example

[edit]
$nltf1echopresscr2readcr3done

The following example numbers only the lines that begin with a capital letter A (matching on theregular expression /^A/).filename is optional.

$nl-bp^Afilename       apple    1  Apple       BANANA    2  Allspice       strawberry

It can be useful as an alternative togrep -n:

$catsomefileaaaabbbbccccdddc$nlsomefile|grepcccc    3 cccc

See also

[edit]

References

[edit]
  1. ^nl – Shell and Utilities Reference,The Single UNIX Specification, Version 4 fromThe Open Group
  2. ^nl(1) – FreeBSD General CommandsManual
  3. ^nl(1) – Linux General CommandsManual
  4. ^"Native Win32 ports of some GNU utilities".unxutils.sourceforge.net.

External links

[edit]
The WikibookGuide to Unix has a page on the topic of:Commands
File system
Processes
User environment
Text processing
Shell builtins
Searching
Documentation
Software development
Miscellaneous
File system
Text utilities
Shell utilities
Retrieved from "https://en.wikipedia.org/w/index.php?title=Nl_(Unix)&oldid=1103094347"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp