How to get the line count of a large file, at least 5G

后端 未结 2 1970
误落风尘
误落风尘 2020-12-30 09:13

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

2条回答
  •  梦毁少年i
    2020-12-30 09:49

    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.

提交回复
热议问题