file(1)file(1)Namefile - determine file type
Syntaxfile [ -c ] [ -f ffile] [ -m mfile] filename ...
Description
The command performs a series of tests on each filename argument in an
attempt to classify it. If an argument appears to be ASCII, the com‐
mand examines the first 1024 bytes and tries to guess its language.
For character special files, part of this classification is information
about which devices the system shows as active. In particular, device-
specific information such as controller type and unit, device type and
unit, and status (offline, write locked, density, errors) is returned.
The general categories currently implemented are disk, tape, and termi‐
nal devices. The supported terminal devices include Local Area Termi‐
nals (LAT) but not Local Area Network (LAN) pseudo-terminals.
The command uses the file to identify files that have some sort of
magic number. A magic number is any numeric or string constant that
identifies the file containing the constant. Commentary at the begin‐
ning of explains its format.
Options-c Checks the magic file for format errors by printing the internal
representation of the magic file. No file typing is done under
-c.
-f Interprets the following argument to be a file containing the
names of the files to be examined.
-m Instructs file to use an alternate magic file.
Restrictions
It often does a poor job of distinguishing C programs, shell scripts,
English text, and ASCII text.
It does not recognize many programming languages, including Modula,
Pascal, and Lisp.
Files
/usr/lib/file/magic
See Alsomagic(5)file(1)