Linux / Unix: Add Line Numbers To Files

To add line numbers to a file in Linux/Unix, you can use the nl command. Here is an example:

nl file.txt > numbered_file.txt

This will create a new file numbered_file.txt with line numbers added to the contents of file.txt. The nl command can also be used with other options and arguments to customize the line numbering.

Leave a Comment