This blog is originated from stackoverflow.com
Step 1: head -n filename < newfile // get the first n lines into newfile,e.g. n =5
Step 2: Get the huge file size, A
Step 3: Get the newfile size,B
Step 4: (A/B)*n is approximately equal to the exact line count.
Set n to be different values,done a few times more, then get the average.
估算大文件行数技巧
本文介绍了一种通过采样来快速估算大文件中行数的方法。步骤包括:选取文件头部若干行保存到新文件,获取原文件及新文件大小进行对比,以此比例推算总行数。该方法适用于无法一次性读取的大文件。
2784

被折叠的 条评论
为什么被折叠?



