The cat
command returns the content of the file and the nl
command adds also the line number. For example:
cat myfile.txt
this is the first line
this is the second line
and this is the third
this should be the forth
Now, if we want to get the line number too, we can run:
nl myfile.txt
1 this is the first line
2 this is the second line
3 and this is the third
4 this should be the forth
Another option is to use the cat
command with the -n
option such as:
cat -n myfile.txt
1 this is the first line
2 this is the second line
3 and this is the third
4 this should be the forth