如何获得一个大文件的行数,至少5G [英] How to get the line count of a large file, at least 5G

查看:144
本文介绍了如何获得一个大文件的行数,至少5G的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得一个大文件的行数,至少5G。使用shell最快的方法。

解决方案

第1步:head -n文件名> newfile //获得前n行到newfile,例如n = 5

步骤2:获取大文件大小A

第三步:获取新文件大小,B

第四步:(A / B)* n大约等于确切的线数。

将n设置为不同的值,再做几次,然后得到平均值。

How to get the line count of a large file, at least 5G. the fastest approach using shell.

解决方案

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.

这篇关于如何获得一个大文件的行数,至少5G的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆