nl

A utility for numbering lines, either from a file, or from stdin. More information: <https://www.gnu.org/software/coreutils/nl>.

Install

All systems
curl cmd.cat/nl.sh
Debian Debian
apt-get install coreutils
Ubuntu
apt-get install coreutils
Alpine
apk add coreutils
Arch Arch Linux
pacman -S coreutils
image/svg+xml Kali Linux
apt-get install coreutils
CentOS
yum install coreutils
Fedora
dnf install coreutils
Windows (WSL2)
sudo apt-get update sudo apt-get install coreutils
OS X
brew install coreutils
Raspbian
apt-get install coreutils
Docker
docker run cmd.cat/nl nl powered by Commando

A utility for numbering lines, either from a file, or from stdin. More information: <https://www.gnu.org/software/coreutils/nl>.

  • Number non-blank lines in a file:
    nl path/to/file
  • Read from `stdout`:
    cat path/to/file | nl options -
  • Number only the lines with printable text:
    nl -t path/to/file
  • Number all lines including blank lines:
    nl -b a path/to/file
  • Number only the body lines that match a basic regular expression (BRE) pattern:
    nl -b p'FooBar[0-9]' path/to/file

© tl;dr; authors and contributors