2016-11-30 21:54:59 +00:00
|
|
|
# nl
|
|
|
|
|
|
|
|
> A utility for numbering lines, either from a file, or from standard input.
|
2021-04-01 16:54:26 +01:00
|
|
|
> More information: <https://www.gnu.org/software/coreutils/nl>.
|
2016-11-30 21:54:59 +00:00
|
|
|
|
2018-01-25 10:11:05 +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
|
|
|
|
2018-01-25 10:11:05 +00:00
|
|
|
- Read from standard output:
|
|
|
|
|
2022-12-04 09:12:49 +00:00
|
|
|
`cat {{path/to/file}} | nl {{options}} -`
|
2018-01-25 10:11:05 +00:00
|
|
|
|
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
|
|
|
|
2018-01-25 10:11:05 +00:00
|
|
|
- Number all lines including blank lines:
|
|
|
|
|
2022-12-04 09:12:49 +00:00
|
|
|
`nl -b a {{path/to/file}}`
|
2018-01-25 10:11:05 +00:00
|
|
|
|
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}}`
|