当前位置:网站首页>如何把大的‘tar‘存档文件分割成特定大小的多个文件
如何把大的‘tar‘存档文件分割成特定大小的多个文件
2022-07-05 13:38:00 【yuyuyuliang00】
你担心通过网络传输或者上传大型文件吗? 现在不用再担心了,因为你可以通过分割你的文件为指定大小块,以比特移动你的文件来处理缓慢的网速。
我们在这里应该简要地利用存档文件地创建斌且分割它们为一个所选大小块。我们使用tar,在Linux上最流行的存档工具之一并使用split工具帮助我们分割存档文件成小块。
在我们进一步前,我们注意如何使用这些工具,tar和split命令的一般语法如下:
# tar options archive-name files
# split options file "prefix”我们研究一些示例来演示主要概念。
示例1:我们可以按如下创建一个存档文件:
[[email protected] ~]# tar -cvjf test.tar.br2 test/*
test/fold/
test/guid.txt
test/perm.txt
test/rock.html
test/Rock.txt
test/Rocky/
test/Rocky/1.txt
test/Rocky/2.txt
test/Rocky/3.txt
test/Rocky/4.txt
test/Rocky/5.txt
test/rocky.c
test/rocky.sh
test/suid.txt
test/test.tar.gz
[[email protected] ~]# ls
test test.tar.br2要确认这个存档文件已经被创建并且也检查它的大小,我们可以使用ls命令:
[[email protected] ~]# ls -lh test.tar.br2
-rw-r--r-- 1 root root 2.9M Jul 3 22:21 test.tar.br2接着使用split工具,我们按以下把test.tar.br2存档文件分割为每个尺寸1M的小块:
[[email protected] ~]# split -b 1M test.tar.br2 "test.tar.br2.part"
[[email protected] ~]# ls -lh
total 5.8M
drwxr-xr-x 4 root root 177 Jul 3 09:04 test
-rw-r--r-- 1 root root 2.9M Jul 3 22:21 test.tar.br2
-rw-r--r-- 1 root root 1.0M Jul 3 22:26 test.tar.br2.partaa
-rw-r--r-- 1 root root 1.0M Jul 3 22:26 test.tar.br2.partab
-rw-r--r-- 1 root root 917K Jul 3 22:26 test.tar.br2.partac
如你从以上命令输出所见,tar存档文件已经被分成了3个部分。
注意:在以上split命令中,选项-b用于指定每个块的尺寸,而"test.tar.br2.part"是分割后创建的每个块文件名称的前缀。
示例2:在这个实例中,我们按如下使用管道连接tar的输出到split:
[[email protected] ~]# tar -cvzf - test/* | split -b 500K - "test_2.tar.gz.part"
test/fold/
test/guid.txt
test/perm.txt
test/rock.html
test/Rock.txt
test/Rocky/
test/Rocky/1.txt
test/Rocky/2.txt
test/Rocky/3.txt
test/Rocky/4.txt
test/Rocky/5.txt
test/rocky.c
test/rocky.sh
test/suid.txt
test/test.tar.gz确认这些文件:
[[email protected] ~]# ls -lh test_2.tar.gz.part*
-rw-r--r-- 1 root root 500K Jul 3 23:41 test_2.tar.gz.partaa
-rw-r--r-- 1 root root 500K Jul 3 23:41 test_2.tar.gz.partab
-rw-r--r-- 1 root root 500K Jul 3 23:41 test_2.tar.gz.partac
-rw-r--r-- 1 root root 500K Jul 3 23:41 test_2.tar.gz.partad
-rw-r--r-- 1 root root 500K Jul 3 23:41 test_2.tar.gz.partae
-rw-r--r-- 1 root root 449K Jul 3 23:41 test_2.tar.gz.partaf在这个示例中,如你注意到我们不需要指定一个存档名称,只要使用'-'符号。
在分割后如何组合tar文件
在Linux中成功分割tar文件或者任何大型文件后,你可以使用cat命令组合这些文件。使用cat是执行组合操作的最高效和可靠方法。
要组合回所有块或tar文件,我们发出以下命令:
[[email protected] back]# ls
test_2.tar.gz.partaa test_2.tar.gz.partac test_2.tar.gz.partae
test_2.tar.gz.partab test_2.tar.gz.partad test_2.tar.gz.partaf
[[email protected] back]# cat test_2.tar.gz.part* > backup.tar.gz
[[email protected] back]# ls
backup.tar.gz test_2.tar.gz.partab test_2.tar.gz.partad test_2.tar.gz.partaf
test_2.tar.gz.partaa test_2.tar.gz.partac test_2.tar.gz.partae我们能够看到在运行cat命令后,它组合我们先前创建的所有小块成相同大小的原先tar存档文件。
解压组合回的文件,检查其中内容:
[[email protected] back]# tar -xvzf backup.tar.gz
test/fold/
test/guid.txt
test/perm.txt
test/rock.html
test/Rock.txt
test/Rocky/
test/Rocky/1.txt
test/Rocky/2.txt
test/Rocky/3.txt
test/Rocky/4.txt
test/Rocky/5.txt
test/rocky.c
test/rocky.sh
test/suid.txt
test/test.tar.gz边栏推荐
- Binder communication process and servicemanager creation process
- [deep learning paper notes] hnf-netv2 for segmentation of brain tumors using multimodal MR imaging
- go map
- js判断数组中是否存在某个元素(四种方法)
- My colleague didn't understand selenium for half a month, so I figured it out for him in half an hour! Easily showed a wave of operations of climbing Taobao [easy to understand]
- 【Hot100】33. 搜索旋转排序数组
- What are the private addresses
- Idea remote debugging agent
- Win10——轻量级小工具
- Aikesheng sqle audit tool successfully completed the evaluation of "SQL quality management platform grading ability" of the Academy of communications and communications
猜你喜欢

Shandong University Summer Training - 20220620

Solve the problem of invalid uni app configuration page and tabbar

嵌入式软件架构设计-消息交互

Interviewer soul torture: why does the code specification require SQL statements not to have too many joins?

Intranet penetration tool NetApp

Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error

Although the volume and price fall, why are the structural deposits of commercial banks favored by listed companies?
![[notes of in-depth study paper]transbtsv2: wider instead of deep transformer for medical image segmentation](/img/70/6de0346df8527af6c88db1ff89947b.png)
[notes of in-depth study paper]transbtsv2: wider instead of deep transformer for medical image segmentation

龙芯派2代烧写PMON和重装系统

STM32 reverse entry
随机推荐
leetcode 10. Regular Expression Matching 正则表达式匹配 (困难)
法国学者:最优传输理论下对抗攻击可解释性探讨
华为推送服务内容,阅读笔记
[MySQL usage Script] catch all MySQL time and date types and related operation functions (3)
Clock cycle
Parsing XML using Dom4j
mysql获得时间
“百度杯”CTF比赛 九月场,Web:SQL
【MySQL 使用秘籍】一网打尽 MySQL 时间和日期类型与相关操作函数(三)
Android本地Sqlite数据库的备份和还原
MATLAB论文图表标准格式输出(干货)
内网穿透工具 netapp
My colleague didn't understand selenium for half a month, so I figured it out for him in half an hour! Easily showed a wave of operations of climbing Taobao [easy to understand]
先写API文档还是先写代码?
jenkins安装
Redis6 transaction and locking mechanism
zabbix 监控
[public class preview]: basis and practice of video quality evaluation
Resttemplate details
一网打尽异步神器CompletableFuture