当前位置:网站首页>如何把大的‘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边栏推荐
- Kafaka log collection
- 山东大学暑期实训一20220620
- 法国学者:最优传输理论下对抗攻击可解释性探讨
- redis6事务和锁机制
- Solve the problem of "unable to open source file" xx.h "in the custom header file on vs from the source
- 【 script secret pour l'utilisation de MySQL 】 un jeu en ligne sur l'heure et le type de date de MySQL et les fonctions d'exploitation connexes (3)
- “百度杯”CTF比赛 九月场,Web:Upload
- With 4 years of working experience, you can't tell five ways of communication between multithreads. Dare you believe it?
- 峰会回顾|保旺达-合规和安全双驱动的数据安全整体防护体系
- Summit review | baowanda - an integrated data security protection system driven by compliance and security
猜你喜欢

Redis6 master-slave replication and clustering
![[daily question] 1200 Minimum absolute difference](/img/2f/9214df63f6d5fafa1f7247c4529643.png)
[daily question] 1200 Minimum absolute difference

When using Tencent cloud for the first time, you can only use webshell connection instead of SSH connection.

Write API documents first or code first?

zabbix 监控

爱可生SQLe审核工具顺利完成信通院‘SQL质量管理平台分级能力’评测

Jasypt configuration file encryption | quick start | actual combat

“百度杯”CTF比赛 九月场,Web:Upload

These 18 websites can make your page background cool

不知道这4种缓存模式,敢说懂缓存吗?
随机推荐
The real king of caching, Google guava is just a brother
私有地址有那些
Personal component - message prompt
“百度杯”CTF比赛 九月场,Web:SQL
mysql获得时间
Can and can FD
个人组件 - 消息提示
真正的缓存之王,Google Guava 只是弟弟
嵌入式软件架构设计-消息交互
go 字符串操作
【公开课预告】:视频质量评价基础与实践
Aikesheng sqle audit tool successfully completed the evaluation of "SQL quality management platform grading ability" of the Academy of communications and communications
MySQL - database query - sort query, paging query
[public class preview]: basis and practice of video quality evaluation
Parsing XML using Dom4j
French scholars: the explicability of counter attack under optimal transmission theory
What about data leakage? " Watson k'7 moves to eliminate security threats
Difference between avc1 and H264
These 18 websites can make your page background cool
Flutter 3.0更新后如何应用到小程序开发中