文件压缩
tar -zcvf test.tar.gz test/
-z:是否同时具有gzip属性,是否需要gzip压缩;
-c:建立一个压缩文件指令;
-v:压缩过程中是否显示文件;
-f :使用档名;
文件分割
split -b 40M -d -a 2 test.tar.gz test.tar.gz.
-b:指定每个文件的大小,单位可以为B、K、M ;
-d:使用数字而不是字母作为后缀名 ;
-a:后缀名长度,默认为2;
文件压缩加分割
tar -cvf - test | split -b 1M - 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
文件解压
tar -zxvf test_new.tar.gz -C ./Directory/
-z:是否同时具有gzip属性,是否需要gzip压缩;
-x:解压缩指令;
-v:压缩过程中是否显示文件;
-f :使用档名;
参考地址:
Linux tar 压缩、解压、分割、合并文件:https://blog.csdn.net/qq_41979513/article/details/98763608
Linux Tar Split压缩解压缩分片压缩解压缩:https://blog.csdn.net/jiayanhui2877/article/details/14222701