MoonPoint Support Logo


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals

Advanced Search
Sun Mon Tue Wed Thu Fri Sat

Thu, Apr 28, 2016 8:28 pm

Counting the number of lines in a file with the find command

A simple way to count the number of lines in a file on a Microsoft Windows system is by using the following command:

find /v /c "" somefile.txt

The /c option counts the number of lines while the /v option displays all lines NOT containing the specified string. Since the null string, i.e. "", is treated as never matching, you should see the number of lines in the file displayed - see the Stupid command-line trick: Counting the number of lines in stdin article at Raymond Chen's Microsoft Developer Blog, The Old New Thing for an explanation of why this works and how a bug in the earliest MS-DOS version of the find command became a feature that remains to this day.

The MS-DOS operating system was an operating system for early IBM PC compatible personal computers provided by Microsoft long before the company created Microsoft Windows. The operating system was commonly found on personal computers (PCs) during the 1980s to the mid 1990s. The operating system was acquired by Microsoft from Seattle Computer Products and modified by Microsoft to meet the needs of IBM for its IBM PC

[/os/windows/commands] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo