有文件 tempfile2.gz(通过文件命令检查)但 gunzip/gzip -d 不起作用

0 linux gzip

我有一个文件(起初是一个文本文件),做xxd -r了它并将其保存到 tempfile2。后来做了file tempfile2,它写道:

tempfile2: gzip compressed data, was "data2.bin", from Unix, last modified: Fri Nov 14 10:32:20 2014, max compression
Run Code Online (Sandbox Code Playgroud)

我试过:

gzip -d tempfile2>tempfile3
gzip -d tempfile2.gz > tempfile3
gzip -d tempfile2.gz > tempfile3.gz
gunzip tempfile2
gunzip tempfile2.gz
gunzip tempfile2 > tempfile3
Run Code Online (Sandbox Code Playgroud)

...所有可能的组合。

这两个都不起作用。它要么说目录中没有这样的文件,要么 unknown suffix -- ignored

Ant*_*hon 6

你没有tempfile2.gz你只有一个tempfile2

通过做解压

gzip -d  < tempfile2 > tempfile3
Run Code Online (Sandbox Code Playgroud)

通常 gzip 需要一个.gz用于解压的文件,所以你可以这样做

mv tempfile2 tempfile2.gz
gzip -d tempfile2.gz
Run Code Online (Sandbox Code Playgroud)

这会给你一个未压缩的tempfile2. 或者你可以做

mv tempfile2 tempfile2.gz
gzip -cd tempfile2.gz > tempfile3
Run Code Online (Sandbox Code Playgroud)

-c确保输出写到标准输出。或者做

zcat tempfile2 > tempfile3
Run Code Online (Sandbox Code Playgroud)

所以你不需要提供任何选项,选择正确的选项似乎是你问题的根源。