在linux上使用unzip解压一个.zip文件时,如果遇到下面这样的错误:

 Archive:  common_library.zip
   End-of-central-directory signature not found.  Either this file is not
   a zipfile, or it constitutes one disk of a multi-part archive.  In the
   latter case the central directory and zipfile comment will be found on
   the last disk(s) of this archive.
 unzip:  cannot find zipfile directory in one of common_library.zip or
         common_library.zip.zip, and cannot find common_library.zip.ZIP, period.

原因有两种: 1) 以ASCII格式上传了.zip文件 2) .zip文件大小超过了2G。

解决方法安装7za:

wget https://jaist.dl.sourceforge.net/project/p7zip/p7zip/16.02/p7zip_16.02_src_all.tar.bz2

tar -jxvf p7zip_16.02_src_all.tar.bz2
cd p7zip_16.02/
make
sudo make install

 解压文件如下:

7za x linux-xlnx-master.zip -r -o./

参数含义:

x  代表解压缩文件,并且是按原始目录树解压(还有个参数 e 也是解压缩文件,但其会将所有文件都解压到根下,而不是自己原有的文件夹下)

linux-xlnx-master.zip  是压缩文件

-r 表示递归解压缩所有的子文件夹

-o 是指定解压到的目录,-o后是没有空格的,直接接目录。这一点需要注意。

压缩文件如下:

7za a -t7z -r Mytest.7z /home/linux

7za a -tzip -r Mytest.zip /home/linux

参数含义:
a  代表添加文件/文件夹到压缩包

-t 是指定压缩类型,这里定为7z,可不指定,因为7za默认压缩类型就是7z。

-r 表示递归所有的子文件夹

Mytest.7z 是压缩好后的压缩包名

/home/linux:是压缩目标。

注意:7za不仅仅支持.7z压缩格式,还支持.tar.bz2等压缩类型的。如上所述,用-t指定即可。

 

 

 

参考以下:

https://cloud.tencent.com/developer/article/1183245

https://www.cnblogs.com/yiwd/p/3649094.html

https://www.cnblogs.com/littlehb/p/9458787.html

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐