1

有扩展名为 xxx.zip.gz 的双重压缩文件

在 gunzip 上 - 创建大小为 0.25 GB 的
xxx.zip 文件 在 gunzip 后解压缩 - xxx.zip 文件扩展名不会改变

解压缩的输出:

Archive:  xxx.zip
  inflating: xxx.txt

echo $? shows 0 

所以,即使 zip 命令成功完成并且文件仍然带有 zip 扩展名,有什么帮助吗?

操作系统 - SunOS 5.10

4

1 回答 1

1

You're finding the xxx.txt is being created, right?

unzip and gunzip have different "philosophies" about dealing with their archive. gunzip gets rid of the .gz file, while unzip leaves its zip file in place. So in your case, zip is working as designed.

I think the best you can do is

 unzip -q xxx.zip && /bin/rm xxx.zip

This will only delete the zip file if unzip exits without error. The -q option makes unzip quiet, so you won't get the status messages you included above.

edit

as you asked when zip file itself is +10 GB in size, then unzip does not succeed

Assuming that you are certain there is enough diskspace to save the expanded orig file, then it's hard to say. How big is the expanded file? Over 2GB? SunOS5 I believe, used to have file-size limitation at 2GB, requiring a 'large-file' support to be added into kernel and utilities. I don't have access to Sun anymore so can't confirm. I think you'll find places to look with apropos largefile (assuming your $MANPATH is setup correctly).

But the basic test for did the unzip work correctly would be something like

  if unzip "${file}" ; then
     echo "clean unzip for ${file}, deleting the archive file" >&2
     /bin/rm "${file}"
  else
     echo "error running unzip for ${file}, archive file remains in place" >&2
  fi

(Or I don't understand your use case). Feel free to post another question showing ls -l xxx.zip.gz xxx.zip and other details to help reconstruct your expected workflow.

IHTH.

于 2015-02-03T19:50:59.940 回答