How to Find the Number of Lines in a File for Unix

by Kristen Waters

Configuration files, scripts and system logs are all kept in plain text files in the Unix and Linux operating systems. These files can grow quickly. If you want to know how many lines are in a Unix text file, use the "wc" command. This command shows the number of words, lines and characters are in a particular file. Determine the number of lines by counting the newline -- "\n" -- characters in a particular file.


Open a terminal window or log into an SSH session to access a command prompt.


Type the command "wc -l filename" to show the number of lines in the file. Replace "filename" with the exact name of the file.


Press the "Enter" key to display the information on the next line.

About the Author

Kristen Waters has been writing for the computer industry since 2004. She has written training materials for both large and small computer companies as well as how-to and informative articles for many online publications. She holds Bachelor of Science degrees from both York College of Pennsylvania and the University of Maryland.