xref: /minix3/external/bsd/file/dist/doc/file.1 (revision 835f6802383ea18ff9311123031e44be87fb502a)
1*835f6802SDirk Vogt.\"	$NetBSD: file.1,v 1.8 2011/09/16 21:06:25 christos Exp $
2ef01931fSBen Gras.\"
3*835f6802SDirk Vogt.\" $File: file.man,v 1.96 2011/07/12 11:23:38 rrt Exp $
4*835f6802SDirk Vogt.Dd April 20, 2011
5ef01931fSBen Gras.Dt FILE 1
6ef01931fSBen Gras.Os
7ef01931fSBen Gras.Sh NAME
8ef01931fSBen Gras.Nm file
9ef01931fSBen Gras.Nd determine file type
10ef01931fSBen Gras.Sh SYNOPSIS
11ef01931fSBen Gras.Nm
12*835f6802SDirk Vogt.Bk -words
13*835f6802SDirk Vogt.Op Fl bchiklLNnprsvz0
14*835f6802SDirk Vogt.Op Fl Fl apple
15*835f6802SDirk Vogt.Op Fl Fl mime-encoding
16*835f6802SDirk Vogt.Op Fl Fl mime-type
17*835f6802SDirk Vogt.Op Fl e Ar testname
18ef01931fSBen Gras.Op Fl F Ar separator
19ef01931fSBen Gras.Op Fl f Ar namefile
20ef01931fSBen Gras.Op Fl m Ar magicfiles
21*835f6802SDirk Vogt.Ar
22*835f6802SDirk Vogt.Ek
23ef01931fSBen Gras.Nm
24ef01931fSBen Gras.Fl C
25*835f6802SDirk Vogt.Op Fl m Ar magicfiles
26ef01931fSBen Gras.Nm
27ef01931fSBen Gras.Op Fl Fl help
28ef01931fSBen Gras.Sh DESCRIPTION
29*835f6802SDirk VogtThis manual page documents version 5.09 of the
30ef01931fSBen Gras.Nm
31ef01931fSBen Grascommand.
32ef01931fSBen Gras.Pp
33ef01931fSBen Gras.Nm
34ef01931fSBen Grastests each argument in an attempt to classify it.
35ef01931fSBen GrasThere are three sets of tests, performed in this order:
36ef01931fSBen Grasfilesystem tests, magic tests, and language tests.
37ef01931fSBen GrasThe
38ef01931fSBen Gras.Em first
39ef01931fSBen Grastest that succeeds causes the file type to be printed.
40ef01931fSBen Gras.Pp
41ef01931fSBen GrasThe type printed will usually contain one of the words
42ef01931fSBen Gras.Em text
43ef01931fSBen Gras(the file contains only
44ef01931fSBen Grasprinting characters and a few common control
45ef01931fSBen Grascharacters and is probably safe to read on an
46ef01931fSBen Gras.Dv ASCII
47ef01931fSBen Grasterminal),
48ef01931fSBen Gras.Em executable
49ef01931fSBen Gras(the file contains the result of compiling a program
50ef01931fSBen Grasin a form understandable to some
51ef01931fSBen Gras.Tn UNIX
52ef01931fSBen Graskernel or another),
53ef01931fSBen Grasor
54ef01931fSBen Gras.Em data
55ef01931fSBen Grasmeaning anything else (data is usually
56ef01931fSBen Gras.Dq binary
57ef01931fSBen Grasor non-printable).
58ef01931fSBen GrasExceptions are well-known file formats (core files, tar archives)
59ef01931fSBen Grasthat are known to contain binary data.
60ef01931fSBen GrasWhen modifying magic files or the program itself, make sure to
61ef01931fSBen Gras.Em "preserve these keywords" .
62ef01931fSBen GrasUsers depend on knowing that all the readable files in a directory
63ef01931fSBen Grashave the word
64ef01931fSBen Gras.Dq text
65ef01931fSBen Grasprinted.
66ef01931fSBen GrasDon't do as Berkeley did and change
67ef01931fSBen Gras.Dq shell commands text
68ef01931fSBen Grasto
69ef01931fSBen Gras.Dq shell script .
70ef01931fSBen Gras.Pp
71ef01931fSBen GrasThe filesystem tests are based on examining the return from a
72ef01931fSBen Gras.Xr stat 2
73ef01931fSBen Grassystem call.
74ef01931fSBen GrasThe program checks to see if the file is empty,
75ef01931fSBen Grasor if it's some sort of special file.
76ef01931fSBen GrasAny known file types appropriate to the system you are running on
77ef01931fSBen Gras(sockets, symbolic links, or named pipes (FIFOs) on those systems that
78ef01931fSBen Grasimplement them)
79ef01931fSBen Grasare intuited if they are defined in the system header file
80ef01931fSBen Gras.In sys/stat.h .
81ef01931fSBen Gras.Pp
82ef01931fSBen GrasThe magic tests are used to check for files with data in
83ef01931fSBen Grasparticular fixed formats.
84ef01931fSBen GrasThe canonical example of this is a binary executable (compiled program)
85ef01931fSBen Gras.Dv a.out
86ef01931fSBen Grasfile, whose format is defined in
87ef01931fSBen Gras.In elf.h ,
88ef01931fSBen Gras.In a.out.h
89ef01931fSBen Grasand possibly
90ef01931fSBen Gras.In exec.h
91ef01931fSBen Grasin the standard include directory.
92ef01931fSBen GrasThese files have a
93ef01931fSBen Gras.Dq "magic number"
94ef01931fSBen Grasstored in a particular place
95ef01931fSBen Grasnear the beginning of the file that tells the
96ef01931fSBen Gras.Tn UNIX
97ef01931fSBen Grasoperating system
98ef01931fSBen Grasthat the file is a binary executable, and which of several types thereof.
99ef01931fSBen GrasThe concept of a
100ef01931fSBen Gras.Dq "magic"
101ef01931fSBen Grashas been applied by extension to data files.
102ef01931fSBen GrasAny file with some invariant identifier at a small fixed
103ef01931fSBen Grasoffset into the file can usually be described in this way.
104ef01931fSBen GrasThe information identifying these files is read from the compiled
105ef01931fSBen Grasmagic file
106ef01931fSBen Gras.Pa /usr/share/misc/magic.mgc ,
107ef01931fSBen Grasor the files in the directory
108ef01931fSBen Gras.Pa /usr/share/misc/magic
109ef01931fSBen Grasif the compiled file does not exist.
110ef01931fSBen GrasIn addition, if
111ef01931fSBen Gras.Pa $HOME/.magic.mgc
112ef01931fSBen Grasor
113ef01931fSBen Gras.Pa $HOME/.magic
114ef01931fSBen Grasexists, it will be used in preference to the system magic files.
115ef01931fSBen Gras.Pp
116ef01931fSBen GrasIf a file does not match any of the entries in the magic file,
117ef01931fSBen Grasit is examined to see if it seems to be a text file.
118ef01931fSBen GrasASCII, ISO-8859-x, non-ISO 8-bit extended-ASCII character sets
119ef01931fSBen Gras(such as those used on Macintosh and IBM PC systems),
120ef01931fSBen GrasUTF-8-encoded Unicode, UTF-16-encoded Unicode, and EBCDIC
121ef01931fSBen Grascharacter sets can be distinguished by the different
122ef01931fSBen Grasranges and sequences of bytes that constitute printable text
123ef01931fSBen Grasin each set.
124ef01931fSBen GrasIf a file passes any of these tests, its character set is reported.
125ef01931fSBen GrasASCII, ISO-8859-x, UTF-8, and extended-ASCII files are identified
126ef01931fSBen Grasas
127ef01931fSBen Gras.Dq text
128ef01931fSBen Grasbecause they will be mostly readable on nearly any terminal;
129ef01931fSBen GrasUTF-16 and EBCDIC are only
130ef01931fSBen Gras.Dq character data
131ef01931fSBen Grasbecause, while
132ef01931fSBen Grasthey contain text, it is text that will require translation
133ef01931fSBen Grasbefore it can be read.
134ef01931fSBen GrasIn addition,
135ef01931fSBen Gras.Nm
136ef01931fSBen Graswill attempt to determine other characteristics of text-type files.
137ef01931fSBen GrasIf the lines of a file are terminated by CR, CRLF, or NEL, instead
138ef01931fSBen Grasof the Unix-standard LF, this will be reported.
139ef01931fSBen GrasFiles that contain embedded escape sequences or overstriking
140ef01931fSBen Graswill also be identified.
141ef01931fSBen Gras.Pp
142ef01931fSBen GrasOnce
143ef01931fSBen Gras.Nm
144ef01931fSBen Grashas determined the character set used in a text-type file,
145ef01931fSBen Grasit will
146ef01931fSBen Grasattempt to determine in what language the file is written.
147ef01931fSBen GrasThe language tests look for particular strings (cf.
148ef01931fSBen Gras.In names.h )
149ef01931fSBen Grasthat can appear anywhere in the first few blocks of a file.
150ef01931fSBen GrasFor example, the keyword
151ef01931fSBen Gras.Em .br
152ef01931fSBen Grasindicates that the file is most likely a
153ef01931fSBen Gras.Xr troff 1
154ef01931fSBen Grasinput file, just as the keyword
155ef01931fSBen Gras.Em struct
156ef01931fSBen Grasindicates a C program.
157ef01931fSBen GrasThese tests are less reliable than the previous
158ef01931fSBen Grastwo groups, so they are performed last.
159ef01931fSBen GrasThe language test routines also test for some miscellany
160ef01931fSBen Gras(such as
161ef01931fSBen Gras.Xr tar 1
162ef01931fSBen Grasarchives).
163ef01931fSBen Gras.Pp
164ef01931fSBen GrasAny file that cannot be identified as having been written
165ef01931fSBen Grasin any of the character sets listed above is simply said to be
166ef01931fSBen Gras.Dq data .
167ef01931fSBen Gras.Sh OPTIONS
168ef01931fSBen Gras.Bl -tag -width indent
169ef01931fSBen Gras.It Fl b , Fl Fl brief
170ef01931fSBen GrasDo not prepend filenames to output lines (brief mode).
171*835f6802SDirk Vogt.It Fl C , Fl Fl compile
172*835f6802SDirk VogtWrite a
173*835f6802SDirk Vogt.Pa magic.mgc
174*835f6802SDirk Vogtoutput file that contains a pre-parsed version of the magic file or directory.
175ef01931fSBen Gras.It Fl c , Fl Fl checking-printout
176ef01931fSBen GrasCause a checking printout of the parsed form of the magic file.
177ef01931fSBen GrasThis is usually used in conjunction with the
178ef01931fSBen Gras.Fl m
179ef01931fSBen Grasflag to debug a new magic file before installing it.
180ef01931fSBen Gras.It Fl e , Fl Fl exclude Ar testname
181ef01931fSBen GrasExclude the test named in
182ef01931fSBen Gras.Ar testname
183ef01931fSBen Grasfrom the list of tests made to determine the file type.
184ef01931fSBen GrasValid test names are:
185ef01931fSBen Gras.Bl -tag -width compress
186ef01931fSBen Gras.It apptype
187ef01931fSBen Gras.Dv EMX
188ef01931fSBen Grasapplication type (only on EMX).
189*835f6802SDirk Vogt.It ascii
190ef01931fSBen GrasVarious types of text files (this test will try to guess the text
191ef01931fSBen Grasencoding, irrespective of the setting of the
192*835f6802SDirk Vogt.Sq encoding
193ef01931fSBen Grasoption).
194ef01931fSBen Gras.It encoding
195ef01931fSBen GrasDifferent text encodings for soft magic tests.
196ef01931fSBen Gras.It tokens
197ef01931fSBen GrasLooks for known tokens inside text files.
198ef01931fSBen Gras.It cdf
199ef01931fSBen GrasPrints details of Compound Document Files.
200ef01931fSBen Gras.It compress
201ef01931fSBen GrasChecks for, and looks inside, compressed files.
202ef01931fSBen Gras.It elf
203ef01931fSBen GrasPrints ELF file details.
204ef01931fSBen Gras.It soft
205ef01931fSBen GrasConsults magic files.
206ef01931fSBen Gras.It tar
207ef01931fSBen GrasExamines tar files.
208ef01931fSBen Gras.El
209ef01931fSBen Gras.It Fl F , Fl Fl separator Ar separator
210ef01931fSBen GrasUse the specified string as the separator between the filename and the
211ef01931fSBen Grasfile result returned.
212ef01931fSBen GrasDefaults to
213ef01931fSBen Gras.Sq \&: .
214ef01931fSBen Gras.It Fl f , Fl Fl files-from Ar namefile
215ef01931fSBen GrasRead the names of the files to be examined from
216ef01931fSBen Gras.Ar namefile
217ef01931fSBen Gras(one per line)
218ef01931fSBen Grasbefore the argument list.
219ef01931fSBen GrasEither
220ef01931fSBen Gras.Ar namefile
221ef01931fSBen Grasor at least one filename argument must be present;
222ef01931fSBen Grasto test the standard input, use
223ef01931fSBen Gras.Sq -
224ef01931fSBen Grasas a filename argument.
225ef01931fSBen Gras.It Fl h , Fl Fl no-dereference
226*835f6802SDirk Vogtoption causes symlinks not to be followed
227ef01931fSBen Gras(on systems that support symbolic links).
228ef01931fSBen GrasThis is the default if the environment variable
229*835f6802SDirk Vogt.Dv POSIXLY_CORRECT
230ef01931fSBen Grasis not defined.
231ef01931fSBen Gras.It Fl i , Fl Fl mime
232*835f6802SDirk VogtCauses the file command to output mime type strings rather than the more
233ef01931fSBen Grastraditional human readable ones.
234*835f6802SDirk VogtThus it may say
235*835f6802SDirk Vogt.Sq text/plain; charset=us-ascii
236ef01931fSBen Grasrather than
237ef01931fSBen Gras.Dq ASCII text .
238ef01931fSBen Gras.It Fl Fl mime-type , Fl Fl mime-encoding
239ef01931fSBen GrasLike
240ef01931fSBen Gras.Fl i ,
241ef01931fSBen Grasbut print only the specified element(s).
242ef01931fSBen Gras.It Fl k , Fl Fl keep-going
243ef01931fSBen GrasDon't stop at the first match, keep going.
244*835f6802SDirk VogtSubsequent matches will be
245*835f6802SDirk Vogthave the string
246*835f6802SDirk Vogt.Sq "\[rs]012\- "
247ef01931fSBen Grasprepended.
248ef01931fSBen Gras(If you want a newline, see the
249ef01931fSBen Gras.Fl r
250ef01931fSBen Grasoption.)
251*835f6802SDirk Vogt.It Fl l , Fl Fl list
252*835f6802SDirk VogtPrint information about the strength of each magic pattern.
253ef01931fSBen Gras.It Fl L , Fl Fl dereference
254*835f6802SDirk Vogtoption causes symlinks to be followed, as the like-named option in
255ef01931fSBen Gras.Xr ls 1
256ef01931fSBen Gras(on systems that support symbolic links).
257ef01931fSBen GrasThis is the default if the environment variable
258ef01931fSBen Gras.Ev POSIXLY_CORRECT
259ef01931fSBen Grasis defined.
260*835f6802SDirk Vogt.It Fl l
261*835f6802SDirk VogtShows sorted patterns list in the order which is used for the matching.
262*835f6802SDirk Vogt.It Fl m , Fl Fl magic-file Ar magicfiles
263ef01931fSBen GrasSpecify an alternate list of files and directories containing magic.
264ef01931fSBen GrasThis can be a single item, or a colon-separated list.
265ef01931fSBen GrasIf a compiled magic file is found alongside a file or directory,
266ef01931fSBen Grasit will be used instead.
267ef01931fSBen Gras.It Fl N , Fl Fl no-pad
268ef01931fSBen GrasDon't pad filenames so that they align in the output.
269ef01931fSBen Gras.It Fl n , Fl Fl no-buffer
270ef01931fSBen GrasForce stdout to be flushed after checking each file.
271ef01931fSBen GrasThis is only useful if checking a list of files.
272ef01931fSBen GrasIt is intended to be used by programs that want filetype output from a pipe.
273ef01931fSBen Gras.It Fl p , Fl Fl preserve-date
274ef01931fSBen GrasOn systems that support
275ef01931fSBen Gras.Xr utime 3
276ef01931fSBen Grasor
277ef01931fSBen Gras.Xr utimes 2 ,
278ef01931fSBen Grasattempt to preserve the access time of files analyzed, to pretend that
279ef01931fSBen Gras.Nm
280ef01931fSBen Grasnever read them.
281ef01931fSBen Gras.It Fl r , Fl Fl raw
282ef01931fSBen GrasDon't translate unprintable characters to \eooo.
283ef01931fSBen GrasNormally
284ef01931fSBen Gras.Nm
285ef01931fSBen Grastranslates unprintable characters to their octal representation.
286ef01931fSBen Gras.It Fl s , Fl Fl special-files
287ef01931fSBen GrasNormally,
288ef01931fSBen Gras.Nm
289ef01931fSBen Grasonly attempts to read and determine the type of argument files which
290ef01931fSBen Gras.Xr stat 2
291ef01931fSBen Grasreports are ordinary files.
292ef01931fSBen GrasThis prevents problems, because reading special files may have peculiar
293ef01931fSBen Grasconsequences.
294ef01931fSBen GrasSpecifying the
295ef01931fSBen Gras.Fl s
296ef01931fSBen Grasoption causes
297ef01931fSBen Gras.Nm
298ef01931fSBen Grasto also read argument files which are block or character special files.
299ef01931fSBen GrasThis is useful for determining the filesystem types of the data in raw
300ef01931fSBen Grasdisk partitions, which are block special files.
301ef01931fSBen GrasThis option also causes
302ef01931fSBen Gras.Nm
303ef01931fSBen Grasto disregard the file size as reported by
304ef01931fSBen Gras.Xr stat 2
305ef01931fSBen Grassince on some systems it reports a zero size for raw disk partitions.
306ef01931fSBen Gras.It Fl v , Fl Fl version
307ef01931fSBen GrasPrint the version of the program and exit.
308ef01931fSBen Gras.It Fl z , Fl Fl uncompress
309ef01931fSBen GrasTry to look inside compressed files.
310*835f6802SDirk Vogt.It Fl 0 , Fl Fl print0
311*835f6802SDirk VogtOutput a null character
312*835f6802SDirk Vogt.Sq \e0
313*835f6802SDirk Vogtafter the end of the filename.
314*835f6802SDirk VogtNice to
315*835f6802SDirk Vogt.Xr cut 1
316*835f6802SDirk Vogtthe output.
317*835f6802SDirk VogtThis does not affect the separator which is still printed.
318*835f6802SDirk Vogt.It Fl -help
319*835f6802SDirk VogtPrint a help message and exit.
320*835f6802SDirk Vogt.El
321*835f6802SDirk Vogt.Sh FILES
322*835f6802SDirk Vogt.Bl -tag -width /usr/share/misc/magic.mgc -compact
323*835f6802SDirk Vogt.It Pa /usr/share/misc/magic.mgc
324*835f6802SDirk VogtDefault compiled list of magic.
325*835f6802SDirk Vogt.It Pa /usr/share/misc/magic
326*835f6802SDirk VogtDirectory containing default magic files.
327ef01931fSBen Gras.El
328ef01931fSBen Gras.Sh ENVIRONMENT
329ef01931fSBen GrasThe environment variable
330ef01931fSBen Gras.Ev MAGIC
331ef01931fSBen Grascan be used to set the default magic file name.
332ef01931fSBen GrasIf that variable is set, then
333ef01931fSBen Gras.Nm
334ef01931fSBen Graswill not attempt to open
335ef01931fSBen Gras.Pa $HOME/.magic .
336ef01931fSBen Gras.Nm
337ef01931fSBen Grasadds
338ef01931fSBen Gras.Dq Pa .mgc
339ef01931fSBen Grasto the value of this variable as appropriate.
340*835f6802SDirk VogtHowever,
341*835f6802SDirk Vogt.Pa file
342*835f6802SDirk Vogthas to exist in order for
343*835f6802SDirk Vogt.Pa file.mime
344*835f6802SDirk Vogtto be considered.
345ef01931fSBen GrasThe environment variable
346ef01931fSBen Gras.Ev POSIXLY_CORRECT
347ef01931fSBen Grascontrols (on systems that support symbolic links), whether
348ef01931fSBen Gras.Nm
349ef01931fSBen Graswill attempt to follow symlinks or not.
350ef01931fSBen GrasIf set, then
351ef01931fSBen Gras.Nm
352ef01931fSBen Grasfollows symlink, otherwise it does not.
353ef01931fSBen GrasThis is also controlled by the
354ef01931fSBen Gras.Fl L
355ef01931fSBen Grasand
356ef01931fSBen Gras.Fl h
357ef01931fSBen Grasoptions.
358ef01931fSBen Gras.Sh SEE ALSO
359*835f6802SDirk Vogt.Xr magic 5 ,
360ef01931fSBen Gras.Xr hexdump 1 ,
361ef01931fSBen Gras.Xr od 1 ,
362ef01931fSBen Gras.Xr strings 1 ,
363*835f6802SDirk Vogt.Sh STANDARDS CONFORMANCE
364ef01931fSBen GrasThis program is believed to exceed the System V Interface Definition
365ef01931fSBen Grasof FILE(CMD), as near as one can determine from the vague language
366ef01931fSBen Grascontained therein.
367ef01931fSBen GrasIts behavior is mostly compatible with the System V program of the same name.
368ef01931fSBen GrasThis version knows more magic, however, so it will produce
369ef01931fSBen Grasdifferent (albeit more accurate) output in many cases.
370ef01931fSBen Gras.\" URL: http://www.opengroup.org/onlinepubs/009695399/utilities/file.html
371ef01931fSBen Gras.Pp
372ef01931fSBen GrasThe one significant difference
373ef01931fSBen Grasbetween this version and System V
374ef01931fSBen Grasis that this version treats any white space
375ef01931fSBen Grasas a delimiter, so that spaces in pattern strings must be escaped.
376ef01931fSBen GrasFor example,
377ef01931fSBen Gras.Bd -literal -offset indent
378ef01931fSBen Gras\*[Gt]10	string	language impress\ 	(imPRESS data)
379ef01931fSBen Gras.Ed
380ef01931fSBen Gras.Pp
381ef01931fSBen Grasin an existing magic file would have to be changed to
382ef01931fSBen Gras.Bd -literal -offset indent
383ef01931fSBen Gras\*[Gt]10	string	language\e impress	(imPRESS data)
384ef01931fSBen Gras.Ed
385ef01931fSBen Gras.Pp
386ef01931fSBen GrasIn addition, in this version, if a pattern string contains a backslash,
387ef01931fSBen Grasit must be escaped.
388ef01931fSBen GrasFor example
389ef01931fSBen Gras.Bd -literal -offset indent
390ef01931fSBen Gras0	string		\ebegindata	Andrew Toolkit document
391ef01931fSBen Gras.Ed
392ef01931fSBen Gras.Pp
393ef01931fSBen Grasin an existing magic file would have to be changed to
394ef01931fSBen Gras.Bd -literal -offset indent
395ef01931fSBen Gras0	string		\e\ebegindata	Andrew Toolkit document
396ef01931fSBen Gras.Ed
397ef01931fSBen Gras.Pp
398ef01931fSBen GrasSunOS releases 3.2 and later from Sun Microsystems include a
399ef01931fSBen Gras.Nm
400ef01931fSBen Grascommand derived from the System V one, but with some extensions.
401ef01931fSBen GrasThis version differs from Sun's only in minor ways.
402ef01931fSBen GrasIt includes the extension of the
403ef01931fSBen Gras.Sq \*[Am]
404ef01931fSBen Grasoperator, used as,
405ef01931fSBen Grasfor example,
406ef01931fSBen Gras.Bd -literal -offset indent
407ef01931fSBen Gras\*[Gt]16	long\*[Am]0x7fffffff	\*[Gt]0		not stripped
408ef01931fSBen Gras.Ed
409ef01931fSBen Gras.Sh MAGIC DIRECTORY
410ef01931fSBen GrasThe magic file entries have been collected from various sources,
411ef01931fSBen Grasmainly USENET, and contributed by various authors.
412ef01931fSBen GrasChristos Zoulas (address below) will collect additional
413ef01931fSBen Grasor corrected magic file entries.
414ef01931fSBen GrasA consolidation of magic file entries
415ef01931fSBen Graswill be distributed periodically.
416ef01931fSBen Gras.Pp
417ef01931fSBen GrasThe order of entries in the magic file is significant.
418ef01931fSBen GrasDepending on what system you are using, the order that
419ef01931fSBen Grasthey are put together may be incorrect.
420ef01931fSBen GrasIf your old
421ef01931fSBen Gras.Nm
422ef01931fSBen Grascommand uses a magic file,
423ef01931fSBen Graskeep the old magic file around for comparison purposes
424ef01931fSBen Gras(rename it to
425ef01931fSBen Gras.Pa /usr/share/misc/magic.orig ) .
426*835f6802SDirk Vogt.Sh EXAMPLES
427*835f6802SDirk Vogt.Bd -literal -offset indent
428*835f6802SDirk Vogt$ file file.c file /dev/{wd0a,hda}
429*835f6802SDirk Vogtfile.c:   C program text
430*835f6802SDirk Vogtfile:     ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
431*835f6802SDirk Vogt          dynamically linked (uses shared libs), stripped
432*835f6802SDirk Vogt/dev/wd0a: block special (0/0)
433*835f6802SDirk Vogt/dev/hda: block special (3/0)
434*835f6802SDirk Vogt
435*835f6802SDirk Vogt$ file -s /dev/wd0{b,d}
436*835f6802SDirk Vogt/dev/wd0b: data
437*835f6802SDirk Vogt/dev/wd0d: x86 boot sector
438*835f6802SDirk Vogt
439*835f6802SDirk Vogt$ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
440*835f6802SDirk Vogt/dev/hda:   x86 boot sector
441*835f6802SDirk Vogt/dev/hda1:  Linux/i386 ext2 filesystem
442*835f6802SDirk Vogt/dev/hda2:  x86 boot sector
443*835f6802SDirk Vogt/dev/hda3:  x86 boot sector, extended partition table
444*835f6802SDirk Vogt/dev/hda4:  Linux/i386 ext2 filesystem
445*835f6802SDirk Vogt/dev/hda5:  Linux/i386 swap file
446*835f6802SDirk Vogt/dev/hda6:  Linux/i386 swap file
447*835f6802SDirk Vogt/dev/hda7:  Linux/i386 swap file
448*835f6802SDirk Vogt/dev/hda8:  Linux/i386 swap file
449*835f6802SDirk Vogt/dev/hda9:  empty
450*835f6802SDirk Vogt/dev/hda10: empty
451*835f6802SDirk Vogt
452*835f6802SDirk Vogt$ file -i file.c file /dev/{wd0a,hda}
453*835f6802SDirk Vogtfile.c:      text/x-c
454*835f6802SDirk Vogtfile:        application/x-executable
455*835f6802SDirk Vogt/dev/hda:    application/x-not-regular-file
456*835f6802SDirk Vogt/dev/wd0a:   application/x-not-regular-file
457*835f6802SDirk Vogt
458*835f6802SDirk Vogt.Ed
459ef01931fSBen Gras.Sh HISTORY
460ef01931fSBen GrasThere has been a
461ef01931fSBen Gras.Nm
462ef01931fSBen Grascommand in every
463ef01931fSBen Gras.Dv UNIX since at least Research Version 4
464ef01931fSBen Gras(man page dated November, 1973).
465ef01931fSBen GrasThe System V version introduced one significant major change:
466ef01931fSBen Grasthe external list of magic types.
467ef01931fSBen GrasThis slowed the program down slightly but made it a lot more flexible.
468ef01931fSBen Gras.Pp
469ef01931fSBen GrasThis program, based on the System V version,
470ef01931fSBen Graswas written by Ian Darwin
471ef01931fSBen Gras.Aq ian@darwinsys.com
472ef01931fSBen Graswithout looking at anybody else's source code.
473ef01931fSBen Gras.Pp
474ef01931fSBen GrasJohn Gilmore revised the code extensively, making it better than
475ef01931fSBen Grasthe first version.
476ef01931fSBen GrasGeoff Collyer found several inadequacies
477ef01931fSBen Grasand provided some magic file entries.
478ef01931fSBen GrasContributions by the
479ef01931fSBen Gras.Sq \*[Am]
480*835f6802SDirk Vogtoperator by Rob McMahon,
481*835f6802SDirk Vogt.Aq cudcv@warwick.ac.uk ,
482*835f6802SDirk Vogt1989.
483ef01931fSBen Gras.Pp
484*835f6802SDirk VogtGuy Harris,
485*835f6802SDirk Vogt.Aq guy@netapp.com ,
486*835f6802SDirk Vogtmade many changes from 1993 to the present.
487*835f6802SDirk Vogt1989.
488ef01931fSBen Gras.Pp
489ef01931fSBen GrasPrimary development and maintenance from 1990 to the present by
490ef01931fSBen GrasChristos Zoulas
491ef01931fSBen Gras.Aq christos@astron.com .
492ef01931fSBen Gras.Pp
493*835f6802SDirk VogtAltered by Chris Lowth
494*835f6802SDirk Vogt.Aq chris@lowth.com ,
495*835f6802SDirk Vogt2000: handle the
496ef01931fSBen Gras.Fl i
497ef01931fSBen Grasoption to output mime type strings, using an alternative
498ef01931fSBen Grasmagic file and internal logic.
499ef01931fSBen Gras.Pp
500ef01931fSBen GrasAltered by Eric Fischer
501ef01931fSBen Gras.Aq enf@pobox.com ,
502ef01931fSBen GrasJuly, 2000,
503ef01931fSBen Grasto identify character codes and attempt to identify the languages
504ef01931fSBen Grasof non-ASCII files.
505ef01931fSBen Gras.Pp
506ef01931fSBen GrasAltered by Reuben Thomas
507ef01931fSBen Gras.Aq rrt@sc3d.org ,
508*835f6802SDirk Vogt2007-2011, to improve MIME support, merge MIME and non-MIME magic,
509*835f6802SDirk Vogtsupport directories as well as files of magic, apply many bug fixes,
510*835f6802SDirk Vogtupdate and fix a lot of magic, improve the build system, improve the
511*835f6802SDirk Vogtdocumentation, and rewrite the Python bindings in pure Python.
512ef01931fSBen Gras.Pp
513ef01931fSBen GrasThe list of contributors to the
514ef01931fSBen Gras.Sq magic
515ef01931fSBen Grasdirectory (magic files)
516ef01931fSBen Grasis too long to include here.
517ef01931fSBen GrasYou know who you are; thank you.
518ef01931fSBen GrasMany contributors are listed in the source files.
519ef01931fSBen Gras.Sh LEGAL NOTICE
520ef01931fSBen GrasCopyright (c) Ian F. Darwin, Toronto, Canada, 1986-1999.
521ef01931fSBen GrasCovered by the standard Berkeley Software Distribution copyright; see the file
522*835f6802SDirk VogtCOPYING in the source distribution.
523ef01931fSBen Gras.Pp
524ef01931fSBen GrasThe files
525ef01931fSBen Gras.Pa tar.h
526ef01931fSBen Grasand
527ef01931fSBen Gras.Pa is_tar.c
528ef01931fSBen Graswere written by John Gilmore from his public-domain
529ef01931fSBen Gras.Xr tar 1
530ef01931fSBen Grasprogram, and are not covered by the above license.
531*835f6802SDirk Vogt.Sh RETURN CODE
532ef01931fSBen Gras.Nm
533*835f6802SDirk Vogtreturns 0 on success, and non-zero on error.
534*835f6802SDirk Vogt.Sh BUGS
535ef01931fSBen Gras.Pp
536*835f6802SDirk VogtPlease report bugs and send patches to the bug tracker at
537*835f6802SDirk Vogt.Pa http://bugs.gw.com/
538*835f6802SDirk Vogtor the mailing list at
539*835f6802SDirk Vogt.Aq file@mx.gw.com .
540*835f6802SDirk Vogt.Sh TODO
541ef01931fSBen Gras.Pp
542*835f6802SDirk VogtFix output so that tests for MIME and APPLE flags are not needed all
543*835f6802SDirk Vogtover the place, and actual output is only done in one place. This
544*835f6802SDirk Vogtneeds a design. Suggestion: push possible outputs on to a list, then
545*835f6802SDirk Vogtpick the last-pushed (most specific, one hopes) value at the end, or
546*835f6802SDirk Vogtuse a default if the list is empty. This should not slow down evaluation.
547ef01931fSBen Gras.Pp
548*835f6802SDirk VogtContinue to squash all magic bugs. See Debian BTS for a good source.
549ef01931fSBen Gras.Pp
550*835f6802SDirk VogtStore arbitrarily long strings, for example for %s patterns, so that
551*835f6802SDirk Vogtthey can be printed out. Fixes Debian bug #271672. Would require more
552*835f6802SDirk Vogtcomplex store/load code in apprentice.
553ef01931fSBen Gras.Pp
554*835f6802SDirk VogtAdd syntax for relative offsets after current level (Debian bug #466037).
555*835f6802SDirk Vogt.Pp
556*835f6802SDirk VogtMake file -ki work, i.e. give multiple MIME types.
557*835f6802SDirk Vogt.Pp
558*835f6802SDirk VogtAdd a zip library so we can peek inside Office2007 documents to
559*835f6802SDirk Vogtfigure out what they are.
560*835f6802SDirk Vogt.Pp
561*835f6802SDirk VogtAdd an option to print URLs for the sources of the file descriptions.
562ef01931fSBen Gras.Sh AVAILABILITY
563ef01931fSBen GrasYou can obtain the original author's latest version by anonymous FTP
564ef01931fSBen Grason
565ef01931fSBen Gras.Pa ftp.astron.com
566ef01931fSBen Grasin the directory
567ef01931fSBen Gras.Pa /pub/file/file-X.YZ.tar.gz .
568