version 1.22, 2004/10/14 20:56:57 |
version 1.23, 2004/12/04 19:55:12 |
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
.\" SUCH DAMAGE. |
.\" SUCH DAMAGE. |
.\" |
.\" |
.Dd July 30, 1997 |
.Dd December 4, 2004 |
.Dt FILE 1 |
.Dt FILE 1 |
.Os |
.Os |
.Sh NAME |
.Sh NAME |
|
|
.Nd determine file type |
.Nd determine file type |
.Sh SYNOPSIS |
.Sh SYNOPSIS |
.Nm file |
.Nm file |
.Op Fl vbczL |
.Op Fl bckLNnrsvz |
|
.Op Fl F Ar separator |
.Op Fl f Ar namefile |
.Op Fl f Ar namefile |
.Op Fl m Ar magicfiles |
.Op Fl m Ar magicfiles |
.Ar file Op Ar ... |
.Bk -words |
|
.Ar file ... |
|
.Ek |
|
.Nm file |
|
.Op Fl m Ar magicfiles |
|
.Fl C |
.Sh DESCRIPTION |
.Sh DESCRIPTION |
The |
The |
.Nm |
.Nm |
|
|
.Aq Pa a.out.h |
.Aq Pa a.out.h |
and possibly |
and possibly |
.Aq Pa exec.h |
.Aq Pa exec.h |
in the standard include directory. |
in the standard include directory and is explained in |
|
.Xr a.out 5 . |
These files have a |
These files have a |
.Dq magic number |
.Dq magic number |
stored in a particular place |
stored in a particular place |
|
|
.Pp |
.Pp |
The options are as follows: |
The options are as follows: |
.Bl -tag -width Ds |
.Bl -tag -width Ds |
.It Fl v |
|
Print the version of the program and exit. |
|
.It Fl m Ar list |
|
Specify an alternate |
|
.Ar list |
|
of files containing magic numbers. |
|
This can be a single file, or a colon-separated list of files. |
|
.It Fl z |
|
Try to look inside compressed files. |
|
.It Fl b |
.It Fl b |
Do not prepend filenames to output lines (brief mode). |
Do not prepend filenames to output lines (brief mode). |
|
.It Fl C |
|
For each magic number file, write a |
|
.Pa magic.mgc |
|
output file that contains a preparsed (compiled) version of it. |
.It Fl c |
.It Fl c |
Cause a checking printout of the parsed form of the magic file. |
Cause a checking printout of the parsed form of the magic file. |
This is usually used in conjunction with |
This is usually used in conjunction with |
.Fl m |
.Fl m |
to debug a new magic file before installing it. |
to debug a new magic file before installing it. |
|
.It Fl F Ar separator |
|
Use the specified string as the separator between the filename and |
|
the file result returned. |
|
Defaults to |
|
.Sq \&: . |
.It Fl f Ar namefile |
.It Fl f Ar namefile |
Read the names of the files to be examined from |
Read the names of the files to be examined from |
.Ar namefile |
.Ar namefile |
|
|
.Ar namefile |
.Ar namefile |
or at least one filename argument must be present; |
or at least one filename argument must be present; |
to test the standard input, use |
to test the standard input, use |
.Dq - |
.Sq - |
as a filename argument. |
as a filename argument. |
|
.It Fl k |
|
Don't stop at the first match, keep going. |
.It Fl L |
.It Fl L |
Cause symlinks to be followed, as the like-named option in |
Cause symlinks to be followed, as the like-named option in |
.Xr ls 1 . |
.Xr ls 1 |
(on systems that support symbolic links). |
(on systems that support symbolic links). |
|
.It Fl m Ar magiclist |
|
Specify an alternate list, |
|
.Ar magiclist , |
|
of files containing magic numbers. |
|
This can be a single file or a colon-separated list of files. |
|
If a compiled magic file is found alongside, it will be used instead. |
|
.It Fl N |
|
Don't pad filenames so that they align in the output. |
|
.It Fl n |
|
Force |
|
.Em stdout |
|
to be flushed after checking each file. |
|
This is only useful if checking a list of files. |
|
It is intended to be used by programs that want filetype output from a |
|
pipe. |
|
.It Fl r |
|
Don't translate unprintable characters to |
|
.Sq \e Ns Em ooo . |
|
Normally |
|
.Nm |
|
translates unprintable characters to their octal representation |
|
(raw mode). |
|
.It Fl s |
|
Normally, |
|
.Nm |
|
only attempts to read and determine the type of argument files which |
|
.Xr stat 2 |
|
reports are ordinary files. |
|
This prevents problems, because reading special files may have peculiar |
|
consequences. |
|
Specifying the |
|
.Fl s |
|
option causes |
|
.Nm |
|
to also read argument files which are block or character special files. |
|
This is useful for determining the filesystem types of the data in raw |
|
disk partitions, which are block special files. |
|
This option also causes |
|
.Nm |
|
to disregard the file size as reported by |
|
.Xr stat 2 , |
|
since on some systems it reports a zero size for raw disk partitions. |
|
.It Fl v |
|
Print the version of the program and exit. |
|
.It Fl z |
|
Try to look inside files that have been run through |
|
.Xr compress 1 . |
.El |
.El |
.Sh ENVIRONMENT |
.Sh ENVIRONMENT |
.Bl -tag -width indent |
.Bl -tag -width indent |
.It Ev MAGIC |
.It Ev MAGIC |
Default magic number files. |
Default magic number files, separated by colon characters. |
|
.Nm |
|
adds |
|
.Dq .mgc |
|
to the value of this variable as appropriate. |
.El |
.El |
.Sh FILES |
.Sh FILES |
.Bl -tag -width /etc/magic -compact |
.Bl -tag -width /etc/magic -compact |
|
|
default list of magic numbers |
default list of magic numbers |
.El |
.El |
.Sh SEE ALSO |
.Sh SEE ALSO |
|
.Xr compress 1 , |
.Xr hexdump 1 , |
.Xr hexdump 1 , |
|
.Xr ls 1 , |
.Xr od 1 , |
.Xr od 1 , |
.Xr strings 1 , |
.Xr strings 1 , |
|
.Xr a.out 5 , |
.Xr magic 5 |
.Xr magic 5 |
.Sh STANDARDS CONFORMANCE |
.Sh STANDARDS CONFORMANCE |
This program is believed to exceed the System V Interface Definition |
This program is believed to exceed the System V Interface Definition |
|
|
.An Geoff Collyer |
.An Geoff Collyer |
found several inadequacies |
found several inadequacies |
and provided some magic file entries. |
and provided some magic file entries. |
|
Contributions to the |
|
.Ql & |
|
operator by |
|
.An Rob McMahon Aq cudcv@warwick.ac.uk , |
|
1989. |
.Pp |
.Pp |
|
.An Guy Harris Aq guy@auspex.com |
|
made many changes from 1993 to the present. |
|
.Pp |
|
Primary development and maintenence from 1990 to the present by |
|
.An Christos Zoulas Aq christos@zoulas.com . |
|
.Pp |
Altered by |
Altered by |
.An Rob McMahon Aq cudcv@warwick.ac.uk , |
.An Chris Lowth Aq chris@lowth.com , |
1989, to extend the |
2000: Handle the |
.Ql & |
.Fl i |
operator from simple |
option to output mime type strings and using an alternative magic file |
.Dq x&y != 0 |
and internal logic. |
to |
|
.Dq x&y op z . |
|
.Pp |
.Pp |
Altered by |
Altered by |
.An Guy Harris Aq guy@auspex.com , |
.An Eric Fischer Aq enf@pobox.com , |
1993, to: |
July, 2000, to identify character codes and attempt to identify the |
.Bl -item -offset indent |
languages of non-ASCII files. |
.It |
|
put the |
|
.Dq old-style |
|
.Ql & |
|
operator back the way it was, because |
|
.Bl -enum -offset indent |
|
.It |
|
Rob McMahon's change broke the |
|
previous style of usage, |
|
.It |
|
The SunOS |
|
.Dq new-style |
|
.Ql & |
|
operator, which this version of |
|
.Nm |
|
supports, also handles |
|
.Dq x&y op z , |
|
.It |
|
Rob's change wasn't documented in any case; |
|
.El |
|
.It |
|
put in multiple levels of |
|
.Ql > ; |
|
.It |
|
put in |
|
.Dq beshort , |
|
.Dq leshort , |
|
etc. keywords to look at numbers in the |
|
file in a specific byte order, rather than in the native byte order of |
|
the process running |
|
.Nm file . |
|
.El |
|
.Pp |
.Pp |
Currently maintained by |
The list of contributors to the |
.An Christos Zoulas Aq christos@zoulas.com . |
.Dq magdir |
|
directory (source for the |
|
.Pa /etc/magic |
|
file) is too long to include here. |
|
You know who you are; thank you. |
.Sh LEGAL NOTICE |
.Sh LEGAL NOTICE |
Copyright (c) Ian F. Darwin, Toronto, Canada, 1986-1999. |
Copyright (c) Ian F. Darwin, Toronto, Canada, 1986-1999. |
Covered by the standard Berkeley Software Distribution copyright; see the file |
Covered by the standard Berkeley Software Distribution copyright; see the file |
|
|
.An John Gilmore |
.An John Gilmore |
from his public-domain |
from his public-domain |
.Nm tar |
.Nm tar |
program. |
program, and are not covered by the above license. |
.Sh BUGS |
.Sh BUGS |
There must be a better way to automate the construction of the Magic |
There must be a better way to automate the construction of the Magic |
file from all the glop in Magdir. |
file from all the glop in Magdir. |