【问题标题】:Can't curl then unzip zip file无法卷曲然后解压缩 zip 文件
【发布时间】:2015-05-05 00:33:25
【问题描述】:

我只是想卷曲这个 zip 文件,然后解压缩它

curl -sS https://www.kaggle.com/c/word2vec-nlp-tutorial/download/labeledTrainData.tsv.zip > labeledTrainData.tsv.zip
unzip labeledTrainData.tsv.zip labeledTrainData.tsv

但我不断收到错误消息;

Archive:  labeledTrainData.tsv.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.

我认为我使用的语法与 response 中的语法相同。我下载的文件有问题吗?我觉得我犯了一个菜鸟的错误。我在 shell 脚本中运行这两个命令

【问题讨论】:

  • 此 URL 需要登录。因此,您当前正在下载带有登录表单的网站。
  • @啊,有道理,谢谢!

标签: bash unzip


【解决方案1】:

我能够复制您的错误。这种错误通常表明以下两种情况之一:

  1. 文件未正确打包
  2. 您下载的不是您认为正在下载的内容。

在这种情况下,您的问题是后者。您似乎从错误的 URL 下载文件。当我打开所谓的 zip 文件进行阅读时,我看到了这一点:

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/account/login?ReturnUrl=%2fc%2fword2vec-nlp-tutorial%2fdownload%2flabeledTrainData.tsv.zip">here</a>.</h2>
</body></html>

长话短说,您需要从上面指定的备用 URL 下载。此外,Kaggle 在下载时通常需要登录凭据,因此您还需要指定您的用户名/密码。

【讨论】:

  • 你说得对,这不会那么简单!!谢谢!
  • 如果您将 -L 标志添加到 curl 命令,它应该会为您处理重定向。
  • @mikesigs 您应该将此评论作为答案。它帮助了我。