2016-11-30 21:54:59 +00:00
|
|
|
# nl
|
|
|
|
|
|
|
|
> A utility for numbering lines, either from a file, or from standard input.
|
2021-03-30 14:44:21 +01:00
|
|
|
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/nl-invocation.html>.
|
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
|
|
|
|
2017-04-15 00:05:38 +01:00
|
|
|
`nl {{file}}`
|
2016-11-30 21:54:59 +00:00
|
|
|
|
2018-01-25 10:11:05 +00:00
|
|
|
- Read from standard output:
|
|
|
|
|
|
|
|
`cat {{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
|
|
|
|
2017-04-15 00:05:38 +01:00
|
|
|
`nl -t {{file}}`
|
2016-11-30 21:54:59 +00:00
|
|
|
|
2018-01-25 10:11:05 +00:00
|
|
|
- Number all lines including blank lines:
|
|
|
|
|
|
|
|
`nl -b a {{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
|
|
|
|
2017-04-15 00:05:38 +01:00
|
|
|
`nl -b p'FooBar[0-9]' {{file}}`
|