当前位置:网站首页>如何把大的‘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边栏推荐
- 49. 字母异位词分组:给你一个字符串数组,请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。 字母异位词 是由重新排列源单词的字母得到的一个新单词,所有源单词中的字母通常恰好只用一次。
- Shuttle INKWELL & ink components
- The development of speech recognition app with uni app is simple and fast.
- What is a network port
- Wonderful express | Tencent cloud database June issue
- Solve the problem of invalid uni app configuration page and tabbar
- 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]
- restTemplate详解
- “百度杯”CTF比赛 九月场,Web:Upload
- SAE international strategic investment geometry partner
猜你喜欢

法国学者:最优传输理论下对抗攻击可解释性探讨

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

运筹说 第68期|2022年最新影响因子正式发布 快看管科领域期刊的变化

Backup and restore of Android local SQLite database

Talk about seven ways to realize asynchronous programming

峰会回顾|保旺达-合规和安全双驱动的数据安全整体防护体系

Operational research 68 | the latest impact factors in 2022 were officially released. Changes in journals in the field of rapid care

How to apply the updated fluent 3.0 to applet development

zabbix 监控

“百度杯”CTF比赛 九月场,Web:SQL
随机推荐
Address book (linked list implementation)
The real king of caching, Google guava is just a brother
Programmer growth Chapter 8: do a good job of testing
Win10 - lightweight gadget
JPA规范总结和整理
Idea remote debugging agent
[notes of in-depth study paper]uctransnet: rethink the jumping connection in u-net from the perspective of transformer channel
Operational research 68 | the latest impact factors in 2022 were officially released. Changes in journals in the field of rapid care
【华南理工大学】考研初试复试资料分享
JS to determine whether an element exists in the array (four methods)
“百度杯”CTF比赛 九月场,Web:SQL
Summit review | baowanda - an integrated data security protection system driven by compliance and security
Catch all asynchronous artifact completable future
French scholars: the explicability of counter attack under optimal transmission theory
aspx 简单的用户登录
真正的缓存之王,Google Guava 只是弟弟
Integer = = the comparison will unpack automatically. This variable cannot be assigned empty
不知道这4种缓存模式,敢说懂缓存吗?
“百度杯”CTF比赛 九月场,Web:Upload
[MySQL usage Script] catch all MySQL time and date types and related operation functions (3)