file | |
---|---|
![]() Example usage of file | |
Developer(s) | AT&T Bell Laboratories |
Initial release | 1973Unix Research Version 4; 1986 open-source reimplementation | as part of
Stable release | 5.46[1] ![]() |
Repository | github |
Written in | C |
Operating system | Unix, Unix-like, Plan 9, IBM i |
Platform | Cross-platform |
Type | File type detector |
License | BSD license, CDDL Plan 9: MIT License |
Website | darwinsys |
file
is a shell command for reporting the type of data contained in a file. It is commonly supported in Unix and Unix-like operating systems.
As the command uses relatively quick-running heuristics to determine file type, it can report misleading information. The command can be fooled, for example, by including a magic number in the content even if the rest of the content does not match what the magic number indicates. The command report cannot be taken as completely trustworthy.
The Single UNIX Specification (SUS) requires the command to exhibit the following behavior with respect to the file specified via the command-line:
Position-sensitive tests are normally implemented by matching various locations within the file against a textual database of magic numbers (see the Usage section). This differs from other simpler methods such as file extensions and schemes like MIME.
In the System V implementation, the Ian Darwin implementation, and the OpenBSD implementation, the command uses a database to drive the probing of the lead bytes. That database is stored as a file that is located in /etc/magic
, /usr/share/file/magic
or similar.
© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search