What's an easy way to get a line count or other stats of a file?

Microsoft Windows users
MS-DOS and Windows command line users
Linux and Unix users

Microsoft Windows users

Microsoft Word

Users who have Microsoft Word installed on their computer can view statistics, such as the amount of pages, paragraphs, lines, words, characters, and characters with spaces, by following the steps below.

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

WordPerfect

Users who have Corel WordPerfect installed on their computer can view statistics, such as characters, words, sentences, lines, paragraphs, pages, and other averages of the page by following the steps below.

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

OpenOffice Writer

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

In addition to the above suggestions, there are thousands of different text editors available on the Internet, many of them capable of displaying the statistics of a file.

MS-DOS and Windows command line users

Below is a listing of different methods of getting statistic information on files while in MS-DOS.

Find command

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

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

Edit

Although very limited, the edit command is capable of displaying the amount of lines in a file. To do this, follow the steps below.

  1. Edit the file you want to view the amount of lines in.
  2. Go to the end of the file. If the file is a large file, you can immediately 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.

In addition to the above recommendations, there are several third-party MS-DOS utilities designed specifically to count the amount of lines in a file and get other statistics. Click here to open an external search for these utilities.

Linux and Unix users

OpenOffice Writer

Users who have OpenOffice installed on their computer can view statistics, such as the number of pages, tables, graphics, OLE 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 Properties.
  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, or 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. If you're wanting to see how many lines are in a file, go to the end of the document and press CTRL + C or ^C to get the current position.

vi command and vim command - The vi and vim and its variants are also capable of displaying line and character counts.

In addition to the above commands, users can write shell scripts, Perl scripts, or any scripts or programs to get any details about the file they want.

Additional information

  • See our line definition for further information and related links on this term.