From: Jano Svitok Date: 2007-08-21T07:34:26+09:00 Subject: Re: # of lines in a file On 8/21/07, blufur wrote: > is there built-in method to determine the number of lines in a file? > > i tried file.readlines.length but it is very slow (dealing with files > > 1 million lines) if on unix: `wc -l #{filename}` or similar (I don't remember the exact syntax for wc) otherwise: try counting \r\n or \n. Read file in a loop, counting the occurences. There was a thread recently how to process a file as fast as possible -- search the archives.