如何确定低级文件类型?

如何确定低级文件类型?

file(1),当针对某些文件时,表示例如“Debian 二进制包(格式 2.0)”*.deb或“OpenDocument 文本” *.odt。我想有一种方法来确定使用什么低级类型的存档:例如它可以是阿尔对于 Debian 软件包或 ZIP 对于 OpenDocument 文件。

我怎样才能确定这一点?

答案1

使用7z 16.02或稍后使用lp7zip 中的 (list) 选项

以下是一些输出示例:

奥特

7z l test.odt 

(..)
Scanning the drive for archives:
1 file, 20969 bytes (21 KiB)

Listing archive: test.odt

--
Path = test.odt
Type = zip
Physical Size = 20969
(..)

德布

7z l test.deb 

(..)
Scanning the drive for archives:
1 file, 47320946 bytes (46 MiB)

Listing archive: test.deb

--
Path = test.deb
Type = Ar
Physical Size = 47320946
SubType = deb
----
Path = data.tar.xz
Size = 47310792
Modified = 2017-03-09 00:04:52
Mode = -rw-r--r--
--
Path = data.tar.xz
Type = xz
Physical Size = 47310792
Method = LZMA2:26 CRC32
Streams = 1
Blocks = 1
(..)

转速

7z l test.rpm 

(..)
Scanning the drive for archives:
1 file, 80356 bytes (79 KiB)

Listing archive: test.rpm

--
Path = test.rpm
Type = Rpm
Physical Size = 80356
Headers Size = 7726
CPU = x86_64
Host OS = linux
Created = 2016-06-06 11:01:01
----
Path = test.cpio.gz
Size = 72630
Created = 2016-06-06 11:01:01
--
Path = test.cpio.gz
Type = gzip
Headers Size = 10
(..)

tgz:

7z l test.tgz

Scanning the drive for archives:
1 file, 25617349 bytes (25 MiB)

Listing archive: test.tgz

--
Path = test.tgz
Type = gzip
Headers Size = 10
(..)

非档案:

(..)
ERROR: test.sh : Can not open the file as archive

相关内容