Nl

The nl command outputs the file with line numbers added, as in cat -n. But nl has various options regarding the format of the line numbers and how they are applied. For example:

[email protected]ble:/media/cdron/ > zcat INDEX.gz |nl -n rz | head -n1000| tail -n3

000998 ./CD1/suse/i586/ethtool-1.8-123.i586.rpm

000999 ./CD1/suse/i586/evlog-1.6.0-31.i586.rpm

001000 ./CD1/suse/i586/evlog-devel-1.6.0-31.i586.rpm

In this example, you get the last 3 of the first 1,000 lines of the uncompressed INDEX.gz file (the index file from the SUSE installation media), numbered with the leading zeros option to nl. The -n option enables you to specify a numbering format. Here we have chosen rz for the numbering format, which indicates right justified with leading zeros.

Was this article helpful?

0 0

Post a comment