You can use cat -n or –number option to display line numbers while printing a file using Linux cat command.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
## Add data in your file echo -e "one\ntwo\nthree" > myfile ## Display line number along with file contents cat -n myfile ## returns line number at the begining of each line ## 1 one ## 2 two ## 3 three ## Without any options cat myfile ## returns ##one ##two ##three |