Linux系統split對tar文件進行分片和壓縮


一.簡單說明

在實際的使用場景中,我們可能對壓縮過的tar包上傳到某個服務器或者應用,會涉及超出服務器限制的文件大小。這里我們可以對此文件進行壓縮、分片、合並。

二.實際操作

2.1 壓縮包分片

這里,我有個7.5G的tar.gz的壓縮包,由於上傳的服務器的限制,單次只能上傳到700M,這里我們對此文件進行分片:

[root@yuhaohao test]# ls -alh test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz
-rw-r--r-- 1 root root 7.5G May 18 10:24 test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz
[root@yuhaohao test]# split -b 700M test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz. --verbose
creating file ‘test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz.aa’
creating file ‘test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz.ab’
creating file ‘test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz.ac’
creating file ‘test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz.ad’
creating file ‘test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz.ae’
creating file ‘test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz.af’
creating file ‘test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz.ag’
creating file ‘test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz.ah’
creating file ‘test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz.ai’
creating file ‘test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz.aj’
creating file ‘test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz.ak’

2.2 合並

這里我們合並壓縮的文件到合並前的目錄結構:

[root@harbor_reg 1.5.4.1-Debug]# cat test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar.gz.a* |tar -zxv 
test-1.5.4.1_patch-1.5.2.1_2020-05-15/
test-1.5.4.1_patch-1.5.2.1_2020-05-15/test-hehe-gpu-v1.0.0.tar
test-1.5.4.1_patch-1.5.2.1_2020-05-15/test-hehe-v1.0.0.tar
test-1.5.4.1_patch-1.5.2.1_2020-05-15/test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar
test-1.5.4.1_patch-1.5.2.1_2020-05-15/test-gpu-1.5.4.1_patch-1.5.2.1_2020-05-15.tar
test-1.5.4.1_patch-1.5.2.1_2020-05-15/test-g-1.5.4.1_patch-1.5.2.1_2020-05-15.tar
[root@harbor_reg 1.5.4.1-Debug]# ls -alh test-1.5.4.1_patch-1.5.2.1_2020-05-15/
total 18G
drwxr-xr-x 2 root root  284 May 18 10:05 .
drwxr-xr-x 4 root root 4.0K May 18 17:49 ..
-rw------- 1 root root 6.1G May 18 09:59 test-hehe-gpu-v1.0.0.tar
-rw------- 1 root root 2.3G May 18 10:00 test-hehe-v1.0.0.tar
-rw------- 1 root root 516M May 18 10:05 test-1.5.4.1_patch-1.5.2.1_2020-05-15.tar
-rw------- 1 root root 2.3G May 18 10:02 test-gpu-1.5.4.1_patch-1.5.2.1_2020-05-15.tar
-rw------- 1 root root 6.1G May 18 10:04 test-g-1.5.4.1_patch-1.5.2.1_2020-05-15.tar


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM