split
split is an useful command in linux to split files. I awlays use this command like this
split -d a.txt -l 1000000
which split a.txt to output files of 1000 lines each and have numeric suffixes. For example, if a.txt have 50000000 lines, then this command will split a.txt to x01 x02 x03 x04 x05 .
But there is a situation that there are two files to split at the same time in a multi-process program, the two split command will generate the same output files and then they will cover each other. Obviously it will cause error. Now you can use split like this:
split -d a.txt -l 100000 a_
which will generate output files like a_00 a_01…. Then they will not conflict.
For more infomation about split, refer [^ask ubuntu] here
[^ask ubuntu] : http://askubuntu.com/questions/54579/how-to-split-larger-files-into-smaller-parts
本文介绍了 Linux 下 split 命令的基本用法及如何避免文件名冲突的问题。通过设置不同的输出文件前缀,可以确保多进程同时使用 split 命令时,输出文件不会相互覆盖。
9万+

被折叠的 条评论
为什么被折叠?



