Print files with line numbers for each line in Linux

I was wondering if there is a way to print out files with line number printed as well.  In Linux there is a very easy way – in fact several ways of accomplishing this.  Here are a couple of them which easily lets you print line numbers alongside each line in your file.

  1. cat -n FILE : Though not a part of the standard, most versions of cat have an option, -n, to print line numbers.
  2. pr -n -t FILE : This is another method of printing line numbers in your files.
  3. enscript -C : This is the third method.
  4. nl FILE : But of all the above methods, this one takes the cake.
  5. In all the above cases, the output is printed on the screen. But if you want a post script output, then you can use the command a2ps as follows : a2ps --line-numbers=1 FILE