How to solve gzip: stdin: not in gzip format error

目录

一. 问题说明

二. 问题解决

三. 命令复习


一. 问题说明

当执行 

tar -xzf  /tmp/hadoop-3.3.5.tar.gz -C /home/taiyi/yarn

命令时出现:

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

二. 问题解决

为了知道文件的格式,我们可以执行如下命令:

[root@bi8v ~]# file /tmp/hadoop-3.3.5.tar.gz
/tmp/hadoop-3.3.5.tar.gz: POSIX tar archive

The file, yarn-3.3.5.tar.gz is in the POSIX tar archive (GNU) format instead of the gzip format. It means that the file has only been archived and not compressed using gzip. The name of a file has been changed by adding the “.gz” extension. Now as we know this file is only archived and not compressed, we can extract the file removing the “z” flag as this flag is used for gzipped files only.

yarn-3.3.5.tar.gz是POSIX tar归档文件(GNU)格式,而不是gzip格式。说明文件只是没归档而没有被压缩,只是修改了文件的拓展名.gz.

现在我们可以去掉"z"去解压这个只被归档的文件因为,这个标识只用于gzip文件。

tar -xvf  /tmp/hadoop-3.3.5.tar.gz -C /home/taiyi/yarn

问题解决!

三. 命令复习


压缩
tar czvf 压缩文件名.tar.gz 被压缩文件夹




解压
tar zvxf 压缩文件名.tar.gz -C 目标文件夹

-c  压缩
-x  解压
-z  支持gzip解压文件
-v  显示操作过程
-f  使用档名,请留意,在f之后要立即接档名!不要再加参数!

去除解压目录结构使用  --strip-components N

如: 压缩文件text.tar 中文件信息为 src/src1/src2/text.txt

运行 tar -zxvf text.tar --strip-components 1

结果:src1/src2/text.txt

如果运行 tar -zxvf text.tar --strip-components 3

解压结果为: text.txt

参考:

How to solve gzip: stdin: not in gzip format error

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

roman_日积跬步-终至千里

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值