100 Useful Command-Line Utilities

by Oliver; 2014

69. nl

nl numbers each row in a file. E.g.:
$ cat tmp.txt 
aaa
bbb
ccc
ddd
eee
$ nl -b a tmp.txt 
     1  aaa
     2  bbb
     3  ccc
     4  ddd
     5  eee
You can accomplish a similar thing with awk:
$ cat tmp.txt | awk '{print NR"\t"$0}'
1       aaa
2       bbb
3       ccc
4       ddd
5       eee

<PREV   NEXT>