当前位置:网站首页>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边栏推荐
- 私有地址有那些
- 【云资源】云资源安全管理用什么软件好?为什么?
- A detailed explanation of ASCII code, Unicode and UTF-8
- Clock cycle
- Scientific running robot pancakeswap clip robot latest detailed tutorial
- Solve the problem of invalid uni app configuration page and tabbar
- Zibll theme external chain redirection go page beautification tutorial
- Can and can FD
- When there are too many input boxes such as input transmitted at one time in the form, the post data is intercepted
- 【 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)
猜你喜欢

STM32 reverse entry

Attack and defense world web WP

Intranet penetration tool NetApp

Self built shooting range 2022
Jetpack Compose入门到精通

What happened to the communication industry in the first half of this year?

私有地址有那些

Could not set property 'ID' of 'class xx' with value 'XX' argument type mismatch solution

Network security - Novice introduction

Attack and defense world crypto WP
随机推荐
Jenkins installation
【Hot100】34. Find the first and last positions of elements in a sorted array
Liar report query collection network PHP source code
Solution to the prompt of could not close zip file during phpword use
Win10 - lightweight gadget
Pancake Bulldog robot V2 (code optimized)
Log4j utilization correlation
Jetpack Compose入门到精通
zabbix 监控
Go pointer
记录一下在深度学习-一些bug处理
Redis6 transaction and locking mechanism
stm32逆向入门
MySQL - database query - sort query, paging query
How to apply the updated fluent 3.0 to applet development
Redis6 data type and operation summary
[MySQL usage Script] catch all MySQL time and date types and related operation functions (3)
[notes of in-depth study paper]uctransnet: rethink the jumping connection in u-net from the perspective of transformer channel
STM32 reverse entry
【华南理工大学】考研初试复试资料分享