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
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?