前言:Linux下大于4G的文件就很难下载下来了,所以这是我们需要分割压缩文件

文件压缩

  1. tar -zcvf test.tar.gz test/

文件分割

  1. split -b 40M -d test.tar.gz test.tar.gz.
  2. -b:指定每个文件的大小,单位可以为BKM
  3. -d:使用数字而不是字母作为后缀名
  4. -a:后缀名长度,默认为2
  5. 最后一个参数是生成的文件后缀

文件压缩并分割

tar -czvf - test | split -b 1M -d - test.tar.gz.

注意一下指令中的两个“-”,如果分开执行,就不用”-”。为什么有这个”-”?
man tar
-f, –file [HOSTNAME:]F
Use archive file or device F (default “-”, meaning stdin/stdout). 
Note that “/dev/stdout” is not equivalent to “-”.
Using “/dev/stdout” explicitly can lead to corrupted archive, especially when coupled with “-v”.

文件合并

cat test.tar.gz.* > test_new.tar.gz

文件合并时并解压

cat test.tar.gz.* | tar -xzvf -

文件合并时并解压,指定目录

cat test.tar.gz.* | tar -xzvf - -C path