簡體   English   中英

在Linux上使用tar.zip時出錯

[英]Error when `tar` a `.zip` on Linux

我使用zip命令行和-r選項在Mac OSX上壓縮了目錄。 scp.zip在Linux集群的運行。

如果我嘗試用.zip解壓縮

tar -vxzf foo.zip

在我的機器上工作。 但是同一命令在群集上不起作用。 我得到錯誤

gzip: stdin has more than one entry--rest ignored
tar: Child returned status 2
tar: Error is not recoverable: exiting now

我該如何解決這個問題?

tar命令用於解壓縮TAR歸檔文件而不是zip文件。 您應該使用unzip命令而不是tar

unzip foo.zip

或者在Mac端制作tar.gz存檔,而不是zip文件

tar -cvzf foo.tar.gz ....

您可以使用Linux上現有的tar命令解壓縮該文件。

這個錯誤:

gzip: stdin has more than one entry--rest ignored

意味着tar試圖將zip壓縮文件解壓縮為好像它是gzip壓縮文件一樣,但這並不總是有效(請參閱“ 只有使用'deflation'方法壓縮了單個成員的情況下,gzip才能解壓縮zip創建的文件。 “以獲取更多信息)。

您應該使用unzip foo.zip解壓縮zip歸檔文件。

標准GNU tar不能直接處理.zip文件。 我很驚訝MacOSX會處理它。

問題在於tar知道如何處理gzip文件,這些文件不是 Info-Zip( .zip )格式的文件。 Info-Zip文件旨在處理歸檔和壓縮,而tar則不能。 (現在,大多數tar實現都將根據命令行選項使用適當的壓縮器/解壓縮器來過濾tar文件。)

請在集群上使用unzip 那是設計用來處理.zip文件的程序。 您根本不需要tar

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM