Shell命令将大文件拆分为10个较小的文件 [英] Shell command to split large file into 10 smaller files

查看:136
本文介绍了Shell命令将大文件拆分为10个较小的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个csv导入文件,有3300万行,需要导入到我的数据库。我可以导入它与一个C#控制台应用程序,但然后在导入超时后运行的存储过程。因此,我想将文件拆分为10个较小的文件。



我可以在C#中做,但我怀疑有一个更好的方法使用shell实用程序。我有cygwin安装,可以使用所有常见的Linux shell实用程序。

解决方案

使用 split - 例如分割文件每340万行(应该给你10个文件):



split -l 3400000 p>

$ man split


I have a csv import file with 33 million lines that need to be imported into my database. I can import it with a C# console app but then the stored procedures that run after the import timeout. Consequently I want to split the file into 10 smaller files.

I could do it in C# but I suspect there's a much better approach using shell utilities. I have cygwin installed and can use all the common Linux shell utilities. Is there a neat little combination of commands I could use to split the file?

解决方案

Use split - e.g. to split a file every 3.4 million lines (should give you 10 files):

split -l 3400000

$ man split

这篇关于Shell命令将大文件拆分为10个较小的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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