You can use the cat command concatenate files and show on the screen under Linux or Unix like operating systems. The cat command also number all output lines starting with number one with the following syntax:
cat -n fileNameHere
OR
cat --number foo.c
The -b / --number-nonblank option number all nonempty output lines, starting with one and the syntax is:
cat -b fileNameHere
OR
cat --number--nonblank filename
Finally, you suppress or remove repeated empty output lines with the -s / --squeeze-blank option:
cat -s -n fileNameHere
OR
cat --squeeze-blank -n filename
Say hello to nl command
Use the nl command number lines of files under Linux or Unix oses. The syntax is:
Examples
Create a text file called hello.c as follows:
Use the cat or nl command to display line numbers:
Sample outputs: