我应该查找文件是否使用.bz2或.tar.bz2(不使用文件扩展名)进行压缩,然后进行相应的解压缩。我使用了该file
命令,但是.bz2和.tar.bz2的结果相同。请提出一种方法来区分.bz2和.tar.bz2文件。
运行文件bzcat
并将结果通过管道传输到file
:
$ bzcat somefile.bz2 | file -
/dev/stdin: data # or whatever; this is not a .tar.bz2
$ bzcat otherfile.bz2 | file -
/dev/stdin: POSIX tar archive # this *is* a .tar.bz2
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句