in reply to How To Count Lines In File?
The only reason I am contributing to what seems like a complete thread is because I ran into a similar dilema that had real world impact. In trying to solve my problem (which is too long to get into here), I decided to check out the Unix Reconstruction Project at Perl Power Tools and found that the tcgrep was blazing fast in comparison to anything I was capable of writing.
I spent several days ripping out lines of code until I found what I was looking for and splicing it into my code with a few more optimizations for my very specific environment and was able to actually beat the compiled Unix grep (albeit in a very specific race).
So - if you are trying to count lines, words, characters, paragraphs, or a few other things - I would suggest checking out this.
UPDATE: PPT's port of wc does not use the ultra streamlined version of counting lines in a file, but it does offer all kinds of other support such as UTF support for word counting, etc - that is why I felt it was worth mentioning!
Cheers - L~R
|
---|