解压缩gzip文件

我使用下面的命令压缩了一个文件夹:

tar czvf arch.tar.gz dirname/ 

当我尝试使用下面的命令解压缩它

 tar xvfz arch.tar.gz 

那么它解压缩文件夹,但文件夹的内容保持压缩。

在压缩之前,像index.php这样的文件夹中有文件。 现在解压后有一个文件index.php.gz

请告诉我,我错了。

如果你在tar的输出中有压缩文件,那是因为它们被压缩了。你可以用tar tzvf arch.tar.gz来validation。

嗯,在我的Ubuntu这个命令运行正确。

 strangeman@etalon:~$ tar czvf test.tar.gz test/ test/ test/file1 test/file2 test/file3 test/file4 test/file5 test/file6 test/file7 test/file8 test/file9 test/file0 strangeman@etalon:~$ tar xvfz test.tar.gz test/ test/file1 test/file2 test/file3 test/file4 test/file5 test/file6 test/file7 test/file8 test/file9 test/file0 

我认为你的问题在于你用于tar开关的顺序。 你跑了:

 tar xvfz arch.tar.gz 

正确的顺序会使f开关保持最后:

 tar zxvf arch.tar.gz 

这样,arch.tar.gz是f的一个参数。 我不认为你可以在f之后放置任何其他开关,并在不同的tar实现中获得任何可预测的行为。