split command in linux

来源:互联网 发布:淘宝c店保证金 编辑:程序博客网 时间:2024/06/15 02:09

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

0 0