version 1.17, 2016/04/24 07:02:07 |
version 1.18, 2017/09/20 10:03:34 |
|
|
This manual page documents the format of the magic file as |
This manual page documents the format of the magic file as |
used by the |
used by the |
.Xr file 1 |
.Xr file 1 |
command, version 4.24. |
command. |
The |
|
.Xr file 1 |
.Xr file 1 |
command identifies the type of a file using, |
identifies the type of a file using, |
among other tests, |
among other tests, |
a test for whether the file contains certain |
a test for whether the file contains certain |
.Dq "magic patterns" . |
.Dq "magic patterns" . |
|
|
.Em x |
.Em x |
(which is always true) and a message that is to be used if there are |
(which is always true) and a message that is to be used if there are |
no other matches. |
no other matches. |
|
.It Dv clear |
|
This test is always true and clears the match flag for that level. |
|
It is intended to be used with the default test. |
|
.It Dv name |
|
Define a named magic instance that can be called from another |
|
.Dv use |
|
magic entry, like a subroutine call. |
|
Named instance direct magic offsets are relative to the offset of the |
|
previous matched entry, but indirect offsets are relative to the |
|
beginning of the file as usual. |
|
Named magic entries always match. |
|
.It Dv use |
|
Recursively call the named magic starting from the current offset. |
|
If the name of the referenced instance begins with a |
|
.Dv ^ |
|
then the endianness of the magic is switched; if the magic mentioned |
|
.Dv leshort |
|
for example, |
|
it is treated as |
|
.Dv beshort |
|
and vice versa. |
|
This is useful to avoid duplicating the rules for different endianness. |
.El |
.El |
.Pp |
.Pp |
Each top-level magic pattern (see below for an explanation of levels) |
Each top-level magic pattern (see below for an explanation of levels) |