tldr/pages/common/nl.md

25 lines
534 B
Markdown
Raw Normal View History

2016-11-30 21:54:59 +00:00
# nl
> A utility for numbering lines, either from a file, or from `stdin`.
> More information: <https://www.gnu.org/software/coreutils/nl>.
2016-11-30 21:54:59 +00:00
- Number non-blank lines in a file:
2016-11-30 21:54:59 +00:00
2022-12-04 09:12:49 +00:00
`nl {{path/to/file}}`
2016-11-30 21:54:59 +00:00
- Read from `stdout`:
2022-12-04 09:12:49 +00:00
`cat {{path/to/file}} | nl {{options}} -`
2017-04-15 00:05:38 +01:00
- Number only the lines with printable text:
2016-11-30 21:54:59 +00:00
2022-12-04 09:12:49 +00:00
`nl -t {{path/to/file}}`
2016-11-30 21:54:59 +00:00
- Number all lines including blank lines:
2022-12-04 09:12:49 +00:00
`nl -b a {{path/to/file}}`
2017-04-15 00:05:38 +01:00
- Number only the body lines that match a basic regular expression (BRE) pattern:
2016-11-30 21:54:59 +00:00
2022-12-04 09:12:49 +00:00
`nl -b p'FooBar[0-9]' {{path/to/file}}`