Comments on Linux nl Command Tutorial for Beginners (7 Examples)
Linux offers a lot of text formatting command line tools, with each of them having a different purpose. One such utility is nl, which lets you number lines in files. In this tutorial, we will discuss the basics of this command using some easy to understand examples.
3 Comment(s)
Comments
Hi I would like to ask about rz value. Why there even are zero's there? What's the point of that? I mean, where they came from? Asking because my teacher asked for this to find out why and I can't find the answer anywhere. Thank you in advance.
The only thing I can think of is if you are writing a lot of COBOL and want to quickly renumber your lines. Strip off the old line numbers (using sed or whatever)
Suppose you wanted to sort the following numbers:
7, 8, 9, 10, 11
If whatever you were using to sort them treated them as strings, the sort order would be:
10, 11, 7, 8, 9 (because 1 comes before 7)
If they're zero padded: 07, 08, 09, 10, 11
When you sort them, regardless of whether you treat them as strings or integers, you get:
07, 08, 09, 10, 11 (because 0 comes before 1 - first the first digit gets sorted, then the second digit, and so on)