utility tests each argument and attempts
to determine its type. Three sets of tests are performed:
- Filesystem tests, for example if a file is empty, or a
special file such as a socket or named pipe (FIFO).
- “Magic” tests for data in particular fixed
formats. These are loaded from the /etc/magic
file (or ~/.magic instead if it exists and
file is not running as root). The file format
is described in
- Tests for text files such as plain ASCII or C programming
The first test which succeeds causes the file type to be printed. The type will
often contain one of the words text
only printing characters and is probably safe to read on an ASCII terminal),
(the file contains a compiled
executable program) or data
is a single dash (‘-’),
reads from the standard input.
The options are as follows:
- Does not prepend filenames to output lines.
- Prints a summary of the parsed magic file; usually used for
- Causes symlinks not to be followed. This is the
- Outputs MIME type strings rather than the more traditional
human-readable ones. Thus it may say “text/plain” rather than
- Causes symlinks to be followed.
- Attempts to read block and character device files, not just
- Displays warnings when parsing the magic file or applying
its tests. Usually used for debugging.
- default magic file
utility exits 0 on success,
and >0 if an error occurs.
commands have appeared in many previous
versions of UNIX
. This version was written by
to replace the previous version originally
written by Ian Darwin
There is a large number of contributors to the magic files; many are listed in
the source files.