View a File with Line Numbers

Posted September 4, 2003 by Quinn McHenry in UNIX

Using the cat command in UNIX, a file can be displayed with the line number of each line preceding the line.

Here is an example of displaying the file filename with line numbers:

cat -n filename

 

About Quinn McHenry

Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
View more articles by Quinn McHenry

The Conversation

Follow the reactions below and share your own thoughts.