无效的压缩数据——违反了格式?

tri*_*fic 11 linux bash tar

我想使用tar -zxvf命令从 xxx.tar.gz 文件中提取数据,但出现错误,详细信息如下:

suse11-configserver:/home/webapp/wiki # tar -zxvf dokuwiki.20151010.tar.gz

./dokuwiki/

./dokuwiki/._.htaccess.dist

./dokuwiki/.htaccess.dist

./dokuwiki/bin/

./dokuwiki/conf/

./dokuwiki/._COPYING

./dokuwiki/复制

tar:跳转到下一个头部

gzip: stdin: 无效的压缩数据——违反格式

tar:子返回状态 1

tar:错误不可恢复:现在退出

但是这个命令tar -zxvf dokuwiki.20151010.tar.gzMacOS x系统中运行良好,我想不出原因。

Sto*_*ica 7

你的命令是正确的。但似乎文件已损坏。很容易判断,何时正确提取了某些文件(例如./dokuwiki/.htaccess.dist),而不是其他文件。

重新创建dokuwiki.20151010.tar.gz文件,并确保这样做时不会报告错误。如果您从某处下载文件,请验证校验和,或至少验证文件大小。

最重要的是,文件被错误地创建或下载。您拥有的命令应该可以很好地处理.tar.gz文件。


Jon*_* B. 5

Gzipfixgz实用程序的替代位置

如果您无法fixgz在 gzip.org 的网站上找到,这里有一个指向 archive.org 上可用版本的链接: https fixgz.zip

源代码 fixgz实用程序的

此外,如果它也消失了,下面是该fixgz实用程序的源代码:

/* fixgz attempts to fix a binary file transferred in ascii mode by
 * removing each extra CR when it followed by LF.
 * usage: fixgz  bad.gz fixed.gz

 * Copyright 1998 Jean-loup Gailly <jloup@gzip.org>
 *   This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the author be held liable for any damages
 * arising from the use of this software.

 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely.
 */

#include <stdio.h>

int main(argc, argv)
     int argc;
     char **argv;
{
    int c1, c2; /* input bytes */
    FILE *in;   /* corrupted input file */
    FILE *out;  /* fixed output file */

    if (argc <= 2) {
    fprintf(stderr, "usage: fixgz bad.gz fixed.gz\n");
    exit(1);
    }
    in  = fopen(argv[1], "rb");
    if (in == NULL) {
    fprintf(stderr, "fixgz: cannot open %s\n", argv[1]);
    exit(1);
    }
    out = fopen(argv[2], "wb");
    if (in == NULL) {
    fprintf(stderr, "fixgz: cannot create %s\n", argv[2]);
    exit(1);
    }

    c1 = fgetc(in);

    while ((c2 = fgetc(in)) != EOF) {
    if (c1 != '\r' || c2 != '\n') {
        fputc(c1, out);
    }
    c1 = c2;
    }
    if (c1 != EOF) {
    fputc(c1, out);
    }
    exit(0);
    return 0; /* avoid warning */
}

Run Code Online (Sandbox Code Playgroud)

  • 也可以在这里:https://github.com/yonjar/fixgz (2认同)