当前位置:网站首页>How to divide a large 'tar' archive file into multiple files of a specific size
How to divide a large 'tar' archive file into multiple files of a specific size
2022-07-05 13:47:00 【yuyuyuliang00】
Are you worried about transferring or uploading large files over the network ? Don't worry now , Because you can specify large and small pieces by dividing your file , Move your files in bits to handle slow Internet speeds .
Here we should briefly use the archive files to create bin and divide them into a selected large piece . We use tar, stay Linux One of the most popular archiving tools on split Tools help us split archive files into small pieces .
Before we go any further , We pay attention to how to use these tools ,tar and split The general syntax of the command is as follows :
# tar options archive-name files
# split options file "prefix”Let's study some examples to demonstrate the main concepts .
Example 1: We can create an archive file as follows :
[[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.br2Make sure that the archive file has been created and check its size , We can use ls command :
[[email protected] ~]# ls -lh test.tar.br2
-rw-r--r-- 1 root root 2.9M Jul 3 22:21 test.tar.br2Then use split Tools , We press the following test.tar.br2 Archive files are divided into each size 1M Small pieces :
[[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
As you can see from the above command output ,tar The archive has been divided into 3 Parts of .
Be careful : In the above split In command , Options -b Used to specify the size of each block , and "test.tar.br2.part" Is the prefix of each block file name created after segmentation .
Example 2: In this case , We use pipe connection as follows tar Of output to 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.gzConfirm these documents :
[[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.partafIn this example , If you notice, we don't need to specify an archive name , Just use '-' Symbol .
How to combine after segmentation tar file
stay Linux Successfully split in tar File or any large file , You can use cat Command combines these files . Use cat It is the most efficient and reliable way to perform combined operations .
To combine back all blocks or tar file , We issue the following order :
[[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.partaeWe can see it running cat After the command , It combines all the small pieces we created previously into the same size of the original tar Archive file .
Extract the combined file , Check the contents :
[[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边栏推荐
- Attack and defense world crypto WP
- aspx 简单的用户登录
- 基于微信小程序的订餐系统
- Datapipeline was selected into the 2022 digital intelligence atlas and database development report of China Academy of communications and communications
- Catch all asynchronous artifact completable future
- Address book (linked list implementation)
- 什么叫做信息安全?包含哪些内容?与网络安全有什么区别?
- redis6数据类型及操作总结
- Basic characteristics and isolation level of transactions
- Introduction to Chapter 8 proof problem of njupt "Xin'an numeral base"
猜你喜欢

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

真正的缓存之王,Google Guava 只是弟弟

Redis6 master-slave replication and clustering

Godson 2nd generation burn PMON and reload system

Go array and slice

Win10——轻量级小工具

jenkins安装

STM32 reverse entry

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

Operational research 68 | the latest impact factors in 2022 were officially released. Changes in journals in the field of rapid care
随机推荐
ETCD数据库源码分析——rawnode简单封装
面试官灵魂拷问:为什么代码规范要求 SQL 语句不要过多的 join?
Attack and defense world crypto WP
Interviewer soul torture: why does the code specification require SQL statements not to have too many joins?
PHP character capture notes 2020-09-14
私有地址有那些
STM32 reverse entry
Aspx simple user login
龙芯派2代烧写PMON和重装系统
Integer ==比较会自动拆箱 该变量不能赋值为空
[MySQL usage Script] catch all MySQL time and date types and related operation functions (3)
记录一下在深度学习-一些bug处理
The "Baidu Cup" CTF competition was held in February 2017, Web: explosion-2
What are the private addresses
When there are too many input boxes such as input transmitted at one time in the form, the post data is intercepted
网络安全-HSRP协议
web3.eth. Filter related
【 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)
Record in-depth learning - some bug handling
Ueditor + PHP enables Alibaba cloud OSS upload