当前位置:网站首页>如何把大的‘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边栏推荐
- go 数组与切片
- 【每日一题】1200. 最小绝对差
- Go string operation
- JPA规范总结和整理
- Usage, installation and use of TortoiseSVN
- 私有地址有那些
- Datapipeline was selected into the 2022 digital intelligence atlas and database development report of China Academy of communications and communications
- Could not set property 'ID' of 'class xx' with value 'XX' argument type mismatch solution
- go 字符串操作
- 【Hot100】34. 在排序数组中查找元素的第一个和最后一个位置
猜你喜欢

Summit review | baowanda - an integrated data security protection system driven by compliance and security

今年上半年,通信行业发生了哪些事?

内网穿透工具 netapp

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

南理工在线交流群
![[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

Datapipeline was selected into the 2022 digital intelligence atlas and database development report of China Academy of communications and communications

Solve the problem of invalid uni app configuration page and tabbar

The development of speech recognition app with uni app is simple and fast.

不知道这4种缓存模式,敢说懂缓存吗?
随机推荐
华为推送服务内容,阅读笔记
Operational research 68 | the latest impact factors in 2022 were officially released. Changes in journals in the field of rapid care
stm32逆向入门
Shuttle INKWELL & ink components
js判断数组中是否存在某个元素(四种方法)
Kafaka log collection
记录一下在深度学习-一些bug处理
mysql获得时间
STM32 reverse entry
一文详解ASCII码,Unicode与utf-8
"Baidu Cup" CTF competition in September, web:upload
asp. Net read TXT file
49. 字母异位词分组:给你一个字符串数组,请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。 字母异位词 是由重新排列源单词的字母得到的一个新单词,所有源单词中的字母通常恰好只用一次。
Flutter 3.0更新后如何应用到小程序开发中
aspx 简单的用户登录
SAE international strategic investment geometry partner
Matlab paper chart standard format output (dry goods)
Could not set property ‘id‘ of ‘class XX‘ with value ‘XX‘ argument type mismatch 解决办法
“百度杯”CTF比赛 九月场,Web:Upload
go 字符串操作