Advanced file type hunch

How (exactly) does a utility like the UNIX filecommand guess the file type?

Are there any source codes?

+3
source share
3 answers

It uses various heuristics, mainly signatures, which are described in the configuration file.

man -s 5 magic

will provide a file format.

+10
source

He looks at the magic number in the first octets (2-4?) Of the file.

+4
source

This is quite interesting here :)

+4
source

All Articles