↑ ↓ select, Enter open, Esc close

Number the lines of a file

Adjust the values, the command updates live
user@server
nl -ba /var/www/vhosts/example.com/httpdocs/.htaccess

Prefixes each line with its number. The -ba option numbers all lines including empty ones, so the count matches editors and error messages. Without -ba, nl skips blank lines when counting.

Note: For a targeted search with line numbers, grep -n muster datei is usually faster.

Also searched as

  • show file with line numbers linux
  • print line numbers command line
  • which line is this on

Related one-liners

All in Text processing

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.