Linux: Display First Ten Lines (1-10) With Numbers Command

Linux: Display First Ten Lines (1-10) With Numbers Command

To display the first 10 lines of a file with line numbers in Linux, you can use the "nl" command.

For example, to display the first 10 lines of the file "file.txt" with line numbers, you can use the following command:

nl -n ln file.txt | head -10
Sourc‮e‬:www.lautturi.com

This will display output like this:

1  Line 1
     2  Line 2
     3  Line 3
     4  Line 4
     5  Line 5
     6  Line 6
     7  Line 7
     8  Line 8
     9  Line 9
    10  Line 10

This shows the first 10 lines of the file "file.txt" with line numbers.

You can also use other commands to display the first 10 lines of a file with line numbers, such as "cat -n" or "sed -n '1,10p'".

Created Time:2017-10-30 10:17:44  Author:lautturi