文件壓縮
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