How to get a line count or other stats of a file

Updated: 08/31/2020 by Computer Hope

Many programs and tools provide features to count the number of lines and words, known as line count and word count, in a document. Below are lists of these programs and tools, and instructions on how to get line and word stats.

Online tools

Paste any text into our online text tool to get full statistics on the submitted text. Below are some stats our online tool gives you about your text.

  • First longest word - The first found longest word in your text.
  • First shortest word - The first shortest word in your text.
  • Character count - Total characters in your text.
  • Word count - Total words in your text.
  • Avg word length - The average length of words in your text.
  • Top words - The most common words in your text with no filters.
  • Top non-common words - The most common words with a filter that removes common words like "and" in your text.
  • Sentence count - Total sentences in your text.
  • Longest sentence - The longest sentence in all your text.
  • Avg. sentence length - The average sentence length in your text.
  • Line count - The total lines in your text.
  • Longest line - The longest line found in your text.
  • Vowels - Total vowel count in your text.
  • Consonants - Total consonants in your text.
  • Spaces - Total spaces in your text.
  • Uppercase characters - Total uppercase characters in your text.
  • Lowercase characters - Total lowercase characters in your text.
  • Non-alphanumeric - The number of non-alphanumeric characters in your text.
  • Total Bytes - Total bytes your text requires.
  • Total Bits - The total number of bits your text requires.

Microsoft Windows users

Microsoft Word

Microsoft Word

Users of Microsoft Word can view statistics, such as the number of pages, paragraphs, lines, words, and characters, by following the steps below.

Word 2007 and later

  1. Open Microsoft Word.
  2. Click the Review tab in the Ribbon.
  3. In the Proofing section, click the Word Count option.

Word 2003 and earlier

  1. Open Microsoft Word.
  2. Click File at the top of the window.
  3. Click the Properties option.
  4. In the Properties window, click the Statistics tab.

WordPerfect

Users of Corel WordPerfect can view statistics such as the number of characters, words, sentences, lines, paragraphs, pages, and other document information by following the steps below.

  1. Open WordPerfect.
  2. Click File at the top of the window.
  3. Click the Properties option.
  4. In the Properties window, click the Information tab.

OpenOffice Writer

If you have OpenOffice installed on your computer, it too can display statistics about a file. See the Linux and Unix users section below for steps on getting these stats.

There are also thousands of different text editors available on the Internet, many of them capable of displaying the statistics of a file's contents.

MS-DOS and Windows command line users

Below are different methods of getting statistical information on files while in MS-DOS.

Find command

Using the find command below lists every line that does not contain "&*fake&*" which in every case is not found. Because this command lists each line containing the string of text, you'd get an accurate list of how many text lines are in the file.

find /v /c "&*fake&*" programs.txt

Edit

Although limited, the edit command can display the number of lines in a file. To do this, follow the steps below.

  1. Edit the file you want to view the line count.
  2. Go to the end of the file. If the file is large, get to the end of the file by pressing Ctrl+End on your keyboard.
  3. Once at the end of the file, the Line: in the status bar displays the line number.

Several third-party MS-DOS utilities also exist designed specifically to count the number of lines in a file and get other statistics.

Linux and Unix users

OpenOffice Writer

Users of OpenOffice can view statistics, such as the number of pages, tables, graphics, OLE (Object Linking and Embedding) objects, paragraphs, words, characters, and lines, by following the steps below.

  1. Open OpenOffice Writer.
  2. Click File at the top of the window.
  3. Click the Properties option.
  4. In the Properties window, click the Statistics tab.

From the command line, users have different ways to count and get statistics about files on their computer. Below are a few examples.

wc command - The wc (word count) command is one of the easiest and fastest methods of getting the amount of characters, lines, and words in a file. See this page for additional information and examples of this command.

pico command - Although limited, running the pico command and displaying your current position can give you line and character information. Go to the end of the document and press Ctrl+C or ^C to view the current position and total lines.

vi command and vim command - The vi and vim and its variants can also display the line and character counts.

Also, users can write shell scripts, Perl scripts, or programs to analyze a file's contents.