7

Linux unzip 命令合并解压分卷文件

 1 year ago
source link: https://www.myfreax.com/linux-unzip-command-merges-and-decompresses-sub-volume-files/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Linux unzip 命令合并解压分卷文件

Zip是使用最广泛的存档文件格式,它支持无损数据压缩

Updated At 19 Nov 2022 3 min read
By myfreax
Linux unzip 命令合并解压分卷文件

Linux unzip 命令合并解压分卷文件

ZIP是最广泛使用的存档文件格式,支持无损数据压缩。ZIP文件是一个数据容器,其中包含一个或多个压缩文件或目录。

在本教程中,我们将说明如何在Linux使用unzip命令合并解压分卷文件。

unzip是一个命令行程序,可帮助您列出,测试和解压缩ZIP存档文件。unzip在大多数Linux发行版中均未默认安装,但是您可以使用发行版的软件包管理器安装它。

安装 unzip

要检查您的系统上是否安装unzip,请运行命令unzip --version,命令将会打印unzip的版本号。

如果您的系统上未安装unzip,终端将会提示你bash: command not found: unzip。可以使用发行版的软件包管理器进行安装。

如果你的计算机运行的是基于Debian的Linux发行版,例如Ubuntu,Linux mint,可以运行sudo apt update && sudo apt install unzip安装unzip。

如果你的计算机运行的是基于Redhat的Linux发行版,例如Fedora,CentOS。可以运行sudo yum install unzip安装unzip。

sudo apt install unzip
sudo yum install unzip

zip 命令创建分卷压缩文件

想象一下,您希望将Zip存档存储在文件托管服务上,文件上传大小限制为1GB,但你的Zip文件为5GB。

此时,您可以使用-s选项后跟指定的文件大小创建多个Zip文件。单位可以是k千字节,m兆字节,g千兆字节或t万兆字节。

例如命令zip -s 1g -r archivename.zip directory_name将会在zip文件达到1GB后,创建新的zip文件继续压缩,directory_name是要压缩的目录名称。

zip -s 1g -r archivename.zip directory_name
archivename.zip
archivename.z01
archivename.z02
archivename.z03
archivename.z04

合并解压分卷文件

要解压分卷的文件,请先运行cat命令将多个分卷的压缩文件合并为一个压缩文件。

命令cat archivename.z* > archivename.zip将会打开所有分卷压缩文件并重定向到archivename.zip文件。

当合并多个压缩分卷完成后,请运行unzip命令解压合并后的压缩文件即可获得压缩文件的内容。

cat archivename.z* > archivename.zip
unzip archivename.zip
linux-zip-command-to-split-files.webp

结论

在Linux,您可以使用zip命令创建分卷压缩文件。要在Linux解压缩ZIP存档,可以使用unzip命令。如有任何疑问,请随时发表评论。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK