For faster navigation, this Iframe is preloading the Wikiwand page for nl (Unix).

nl (Unix)

Da Wikipedia, l'enciclopedia libera.

nl
software
GenereUtility
SviluppatoreScott Bartram, David MacKenzie
Sistema operativoMultipiattaforma
Licenzacoreutils: GPLv3+
(licenza libera)

nl è un'utilità e filtro Unix per numerare le linee, sia da un file che dallo standard input, riproducendo l'output sullo standard output.

Permette, tramite apposite argomenti, di numerare tutte le linee (comprese quelle composte solamente da newline) o solamente quelle che contengono una stringa che soddisfa un'espressione regolare.

nl è parte del X/Open Portability Guide a partire dal 1987. È stato ereditato nella prima versione dello standard POSIX.1 e nelle Single Unix Specification.[1] È apparso per la prima volta nel sistema operativo System V versione 2.[2]

La versione di nl inclusa in GNU coreutils è stata scritta da Scott Bartram e David MacKenzie.[3]

Il comando ha una serie di opzioni:

  • a - numera tutte le righe
  • t - righe numeriche con solo testo stampabile
  • n - nessuna numerazione di riga
  • stringa - numera solo le righe che contengono l'espressione regolare definita nella stringa fornita.

L'opzione predefinita applicata è t.

nl supporta anche alcune opzioni della riga di comando.

 $ nl tf
   1 echo press cr
   2 read cr
   3 done

L'esempio seguente numera solo le righe che iniziano con la lettera M maiuscola (che corrisponde all'espressione regolare /^M/). Il nome del file è facoltativo.

$ nl -b p^M nome_file
    mela
  1 Mela
    BANANA
  2 Melone
    fragola

Può essere utile in alternativa a grep -n:

$ cat nome_file
aaaa
bbbb
cccc
dddc
$ nl nome_file | grep cccc
  3 cccc
  1. ^ (EN) nl – Commands & Utilities Reference, The Single UNIX Specification, Issue 7, su The Open Group. URL consultato il 22 novembre 2021.
  2. ^ (EN) nl(1) - Manuale dei comandi generici di FreeBSD, su freebsd.org. URL consultato il 22 novembre 2021.
  3. ^ (EN) nl(1) - Manuale dei comandi generici di Linux, su mankier.com. URL consultato il 22 novembre 2021.

Voci correlate

[modifica | modifica wikitesto]
  • wc (Unix) – comando per il conteggio delle parole
  • cat (Unix) – comando di concatenazione (il flag -n è equivalente a nl -a)
  Portale Informatica: accedi alle voci di Wikipedia che trattano di informatica
{{bottomLinkPreText}} {{bottomLinkText}}
nl (Unix)
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?