🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #151

Re: Better way to find out the number of lines in a file

#151
From: Michael Salmon
Date: Tue, 28 Jul 1992 08:50
26 lines
1179 bytes
In article <1992Jul27.195754.26812@tin.monsanto.com>, bcschu@skws02.monsanto.com (Brett Schultz) writes:
|> This is kind of similar to the how many files in a directory question, but
|> is there a trick to find the number of lines in a file?
|> 
|> Thanks
|> 
|> Brett
|> 
|> PS
|> 
|> The files are big so I don't really want to do a gets loop with a counter
|> unless I have to.

You certainly shouldn't use gets or fgets for that matter, use read or
mmap and count the number of newlines.

-- 

Michael Salmon

#include	<standard.disclaimer>
#include	<witty.saying>
#include	<fancy.pseudo.graphics>

Ericsson Telecom AB
Stockholm
Technical Details
Message-ID: <1992Jul28.085037.5863@ericsson.se>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!ericom!eos.ericsson.se!etxmesa
References: <1992Jul27.195754.26812@tin.monsanto.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.unix.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!ericom!eos.ericsson.se!etxmesa
From: etxmesa@eos.ericsson.se (Michael Salmon)
Subject: Re: Better way to find out the number of lines in a file
Message-ID: <1992Jul28.085037.5863@ericsson.se>
Sender: news@ericsson.se
Nntp-Posting-Host: eos6c02.ericsson.se
Reply-To: etxmesa@eos.ericsson.se (Michael Salmon)
Organization: Ericsson Telecom AB
References:  <1992Jul27.195754.26812@tin.monsanto.com>
Date: Tue, 28 Jul 1992 08:50:37 GMT
Lines: 26