split 5 - minute linux command of

Scenario describes

Usually work, I used to use rz from local to upload files to the server, sz downloaded from the server file to a local, but there are restrictions on the size of the file transfer, such as troubleshooting jvm online, you need to generate a dump file, you may have a large 10G, exceeds the limit, how to download it?

split Split File command of

grammar

split [-<行数>][-l<行数>][-b<字节>][-C<字节>][要切割的文件][输出文件名的前缀][-a<后缀长度>]

- <number of lines> or -l <number of lines>: specify how much each row cut into a small file

-b <byte>: Specifies the number of bytes for each cut into a small file, can also specify where K, M, G and other units

-C <byte>: to -b <byte> similar, but when the cutting will try to maintain the integrity of each row

The output file name prefix: After setting the file name prefix split, split automatically after a prefix number plus the default start from aa

-a <suffix length>: default suffix length is 2, i.e., sequentially sort aa, ab, ac of


split command and the cat command to complete the above problems, troubleshoot problems online site has not, so in order to demonstrate, using dd command (for dd command do not understand can also learn to play, because this highlights the split, so dd for the time being no description) to create a 400MB file, the file name is adsearch.hprof, here assumed that the size of more than 400MB download limit server

dd if=/dev/zero bs=1024 count=409600 of=adsearch.hprof

file

As shown, create a file of 400MB


Then I put adsearch.hprof 100MB file size by splitting, can be split into four files

split -b 100M adsearch.hprof

file

After execution can be seen in the split command, directory swells into four equal size xaa, xab, xac, xad four 100MB of small files. Because we do not specify a prefix, it uses the default prefix x, followed by aa, ab, ac, ad. We can also specify a prefix, such as I have just generated four small files deleted, use the following command to re-slicing down

split -b 100M adsearch.hprof adsearch-

file


Merge documents cat

After splitting the large files, we can put small files downloaded to the local, and then stitching them together again

// 用通配符的形式,要保证该目录下没有其他以adsearch-a为前缀的文件
cat adsearch-a* > adsearch.hprof
// 或者指定文件进行拼接
cat adsearch-aa adsearch-ab adsearch-ac adsearch-ad > adsearch.hprof

file



Remark

The above operation I was on this win the gitbash operation, have the cat command


If that is not only cmd gitbash installed it?

You can copy / b command to splice, where / b represent a specified reproduction in a binary format

copy /b adsearch-aa + adsearch-ab + adsearch-ac + adsearch-ad adsearch.hprof


check

After the split - after the merger, the two documents the same? This is our main concern, we do a file md5, to see whether the same results, you can determine whether a file as a

md5 original file
file

After the merger md5 file (gitbash)
file

After the merger md5 file (cmd)

file

After md5 value of around parity file, results are consistent, that we have no problem operating


summary

When we upload or download relatively large files, you can use split to split large files into smaller files, and then use the cat command to reassemble these small files into large file

Guess you like

Origin www.cnblogs.com/dingaimin/p/11576191.html