How to remove all leading zeros?

To remove all leading zeros from line numbers when using the nl command, you can use the -n ln option instead of -n rz. The -n ln option left-aligns the line numbers without adding any leading zeros.

Example Command

nl -n ln filename.txt

Explanation:

  • -n ln: Left-aligns the line numbers and does not add leading zeros.

Result:

If filename.txt has the following content:

Line 1
Line 2
Line 3

The output will look like this:

1  Line 1
2  Line 2
3  Line 3

Summary

Using nl -n ln will give you line numbers without any leading zeros, effectively removing them and left-aligning the numbers.

0 Comments

no data
Be the first to share your comment!