如何在不解压缩的情况下检查Unix .tar.gz文件是否为有效文件? [英] How to check if a Unix .tar.gz file is a valid file without uncompressing?

查看:565
本文介绍了如何在不解压缩的情况下检查Unix .tar.gz文件是否为有效文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一个问题如何确定数据是否为有效的tar文件而没有文件?,但是我想知道:是否有现成的命令行解决方案?

I have found the question How to determine if data is valid tar file without a file?, but I was wondering: is there a ready made command line solution?

推荐答案

仅获取tarball列表并丢弃输出,而不是解压缩文件呢?

What about just getting a listing of the tarball and throw away the output, rather than decompressing the file?

tar -tzf my_tar.tar.gz >/dev/null

根据评论进行了编辑.谢谢zrajm!

根据评论进行编辑.感谢Frozen Flame!.此测试绝不暗示数据的完整性.因为它是作为磁带归档实用程序设计的,所以tar的大多数实现将允许同一文件的多个副本!

Edit as per comment. Thanks Frozen Flame! This test in no way implies integrity of the data. Because it was designed as a tape archival utility most implementations of tar will allow multiple copies of the same file!

这篇关于如何在不解压缩的情况下检查Unix .tar.gz文件是否为有效文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆