使用 csplit 将大文件分成具有确定名称的小文件 [英] Using csplit to divide a large file in smaller files with a determinated name

查看:28
本文介绍了使用 csplit 将大文件分成具有确定名称的小文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个非常大的纯文本文件,大约有 4000 万行,每行具有相同的长度和格式,我们想使用 csplit 将它逐行拆分为 N 个文件.例如,如果 N 为 80,则生成的文件的名称应为:

Having a very large plaint text file, with about 40 million lines, each line with the same length and format, we want to split it, line by line in N files using csplit. For example, if N is 80, the name of the generated files should be:

FILE00000001.txt
FILE00000002.txt
…
FILE00000080.txt

注意 FILE1.txt、FILE2.txt ... FILE80.txt 对我们无效.谢谢!

Note that FILE1.txt, FILE2.txt … FILE80.txt is not valid for us. Thanks!

推荐答案

我要找的参数是-n 8".下一个示例将 BIG_FILE.txt 拆分为 18 个文件,每个文件 5000 行:

The parameter I was looking for is '-n 8'. Next example splits BIG_FILE.txt into 18 files of 5000 lines each of them:

csplit -f FILE -n 8 /a/b/c/BIG_FILE.txt 5000 {18}

这篇关于使用 csplit 将大文件分成具有确定名称的小文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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