Bash Using cat Display line numbers with output

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Use the --number flag to print line numbers before each line. Alternatively, -n does the same thing.

$ cat --number file

 1  line 1
 2  line 2
 3
 4  line 4
 5  line 5

To skip empty lines when counting lines, use the --number-nonblank, or simply -b.

$ cat -b file

 1  line 1
 2  line 2

 3  line 4
 4  line 5


Got any Bash Question?