[英]How can I split a file into a given number of parts in Perl? (On Unix)
I have several large files, each of which I want to chunk/split it in to predefined number of parts. 我有几个大文件,每个文件我都希望将其分块/分割成预定数量的零件。
Is there an efficient way to do it in Unix (eg via awk/sed/perl)? 在Unix中是否有一种有效的方法(例如通过awk / sed / perl)?
Also each file can have varied number of lines. 每个文件的行数也可以不同。
File1.txt 20,300,055 lines
File2.txt 10,033,221 lines
etc...
如果只想将每个文件拆分为固定行数或字节数的文件,则可以使用split
命令。
you can use csplit, which can split by context. 您可以使用csplit,它可以按上下文拆分。 Check the man/info page of csplit for more info.
检查csplit的man / info页面以获取更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.