File command
From Just Solve the File Format Problem
The File command
The file
command has been a part of unix distributions for many years.
The Debian manpage gives an overview of its functionality
The program source includes a database of heuristics for determining file types, which includes a variety of 'magic numbers' which characterise files. This database is not portable, but is potentially adaptable.
For the source, see:
- FreeBSD port tree (referring to the porting of the original distribution into FreeBSD
- XXX Need more sources!