Sun Mar 15 15:16:58 2009 UTC ()
Specify width for tag list.


(joerg)
diff -r1.17 -r1.18 src/dist/file/doc/file.1

cvs diff -r1.17 -r1.18 src/dist/file/doc/Attic/file.1 (switch to unified diff)

--- src/dist/file/doc/Attic/file.1 2008/08/30 12:16:51 1.17
+++ src/dist/file/doc/Attic/file.1 2009/03/15 15:16:58 1.18
@@ -1,550 +1,550 @@ @@ -1,550 +1,550 @@
1.\" $File: file.man,v 1.73 2008/02/19 17:58:00 rrt Exp $ 1.\" $File: file.man,v 1.73 2008/02/19 17:58:00 rrt Exp $
2.Dd February 19, 2008 2.Dd February 19, 2008
3.Dt FILE 1 3.Dt FILE 1
4.Os 4.Os
5.Sh NAME 5.Sh NAME
6.Nm file 6.Nm file
7.Nd determine file type 7.Nd determine file type
8.Sh SYNOPSIS 8.Sh SYNOPSIS
9.Nm 9.Nm
10.Op Fl bchikLnNprsvz 10.Op Fl bchikLnNprsvz
11.Op Fl -mime-type 11.Op Fl -mime-type
12.Op Fl -mime-encoding 12.Op Fl -mime-encoding
13.Op Fl f Ar namefile 13.Op Fl f Ar namefile
14.Op Fl F Ar separator 14.Op Fl F Ar separator
15.Op Fl m Ar magicfiles 15.Op Fl m Ar magicfiles
16.Ar file 16.Ar file
17.Nm 17.Nm
18.Fl C 18.Fl C
19.Op Fl m Ar magicfile 19.Op Fl m Ar magicfile
20.Nm 20.Nm
21.Op Fl -help 21.Op Fl -help
22.Sh DESCRIPTION 22.Sh DESCRIPTION
23This manual page documents version 4.26 of the 23This manual page documents version 4.26 of the
24.Nm 24.Nm
25command. 25command.
26.Pp 26.Pp
27.Nm 27.Nm
28tests each argument in an attempt to classify it. 28tests each argument in an attempt to classify it.
29There are three sets of tests, performed in this order: 29There are three sets of tests, performed in this order:
30filesystem tests, magic tests, and language tests. 30filesystem tests, magic tests, and language tests.
31The 31The
32.Em first 32.Em first
33test that succeeds causes the file type to be printed. 33test that succeeds causes the file type to be printed.
34.Pp 34.Pp
35The type printed will usually contain one of the words 35The type printed will usually contain one of the words
36.Em text 36.Em text
37(the file contains only 37(the file contains only
38printing characters and a few common control 38printing characters and a few common control
39characters and is probably safe to read on an 39characters and is probably safe to read on an
40.Dv ASCII 40.Dv ASCII
41terminal), 41terminal),
42.Em executable 42.Em executable
43(the file contains the result of compiling a program 43(the file contains the result of compiling a program
44in a form understandable to some  44in a form understandable to some
45.Dv UNIX 45.Dv UNIX
46kernel or another), 46kernel or another),
47or 47or
48.Em data 48.Em data
49meaning anything else (data is usually  49meaning anything else (data is usually
50.Sq binary 50.Sq binary
51or non-printable). 51or non-printable).
52Exceptions are well-known file formats (core files, tar archives) 52Exceptions are well-known file formats (core files, tar archives)
53that are known to contain binary data. 53that are known to contain binary data.
54When modifying magic files or the program itself, make sure to 54When modifying magic files or the program itself, make sure to
55.Em "preserve these keywords" . 55.Em "preserve these keywords" .
56Users depend on knowing that all the readable files in a directory 56Users depend on knowing that all the readable files in a directory
57have the word  57have the word
58.Dq text 58.Dq text
59printed. 59printed.
60Don't do as Berkeley did and change  60Don't do as Berkeley did and change
61.Dq shell commands text 61.Dq shell commands text
62to  62to
63.Dq shell script . 63.Dq shell script .
64.Pp 64.Pp
65The filesystem tests are based on examining the return from a 65The filesystem tests are based on examining the return from a
66.Xr stat 2 66.Xr stat 2
67system call. 67system call.
68The program checks to see if the file is empty, 68The program checks to see if the file is empty,
69or if it's some sort of special file. 69or if it's some sort of special file.
70Any known file types appropriate to the system you are running on 70Any known file types appropriate to the system you are running on
71(sockets, symbolic links, or named pipes (FIFOs) on those systems that 71(sockets, symbolic links, or named pipes (FIFOs) on those systems that
72implement them) 72implement them)
73are intuited if they are defined in 73are intuited if they are defined in
74the system header file 74the system header file
75.In sys/stat.h . 75.In sys/stat.h .
76.Pp 76.Pp
77The magic tests are used to check for files with data in 77The magic tests are used to check for files with data in
78particular fixed formats. 78particular fixed formats.
79The canonical example of this is a binary executable (compiled program) 79The canonical example of this is a binary executable (compiled program)
80.Dv a.out 80.Dv a.out
81file, whose format is defined in  81file, whose format is defined in
82.In elf.h , 82.In elf.h ,
83.In a.out.h 83.In a.out.h
84and possibly 84and possibly
85.In exec.h 85.In exec.h
86in the standard include directory. 86in the standard include directory.
87These files have a  87These files have a
88.Sq "magic number" 88.Sq "magic number"
89stored in a particular place 89stored in a particular place
90near the beginning of the file that tells the  90near the beginning of the file that tells the
91.Dv UNIX operating system 91.Dv UNIX operating system
92that the file is a binary executable, and which of several types thereof. 92that the file is a binary executable, and which of several types thereof.
93The concept of a 93The concept of a
94.Sq "magic" 94.Sq "magic"
95has been applied by extension to data files. 95has been applied by extension to data files.
96Any file with some invariant identifier at a small fixed 96Any file with some invariant identifier at a small fixed
97offset into the file can usually be described in this way. 97offset into the file can usually be described in this way.
98The information identifying these files is read from the compiled 98The information identifying these files is read from the compiled
99magic file 99magic file
100.Pa /usr/tools/share/file/magic.mgc , 100.Pa /usr/tools/share/file/magic.mgc ,
101or the files in the directory 101or the files in the directory
102.Pa /usr/tools/share/file/magic 102.Pa /usr/tools/share/file/magic
103if the compiled file does not exist. In addition, if 103if the compiled file does not exist. In addition, if
104.Pa $HOME/.magic.mgc 104.Pa $HOME/.magic.mgc
105or 105or
106.Pa $HOME/.magic 106.Pa $HOME/.magic
107exists, it will be used in preference to the system magic files. 107exists, it will be used in preference to the system magic files.
108.Pp 108.Pp
109If a file does not match any of the entries in the magic file, 109If a file does not match any of the entries in the magic file,
110it is examined to see if it seems to be a text file. 110it is examined to see if it seems to be a text file.
111ASCII, ISO-8859-x, non-ISO 8-bit extended-ASCII character sets 111ASCII, ISO-8859-x, non-ISO 8-bit extended-ASCII character sets
112(such as those used on Macintosh and IBM PC systems), 112(such as those used on Macintosh and IBM PC systems),
113UTF-8-encoded Unicode, UTF-16-encoded Unicode, and EBCDIC 113UTF-8-encoded Unicode, UTF-16-encoded Unicode, and EBCDIC
114character sets can be distinguished by the different 114character sets can be distinguished by the different
115ranges and sequences of bytes that constitute printable text 115ranges and sequences of bytes that constitute printable text
116in each set. 116in each set.
117If a file passes any of these tests, its character set is reported. 117If a file passes any of these tests, its character set is reported.
118ASCII, ISO-8859-x, UTF-8, and extended-ASCII files are identified 118ASCII, ISO-8859-x, UTF-8, and extended-ASCII files are identified
119as  119as
120.Dq text 120.Dq text
121because they will be mostly readable on nearly any terminal; 121because they will be mostly readable on nearly any terminal;
122UTF-16 and EBCDIC are only  122UTF-16 and EBCDIC are only
123.Dq character data 123.Dq character data
124because, while 124because, while
125they contain text, it is text that will require translation 125they contain text, it is text that will require translation
126before it can be read. 126before it can be read.
127In addition, 127In addition,
128.Nm 128.Nm
129will attempt to determine other characteristics of text-type files. 129will attempt to determine other characteristics of text-type files.
130If the lines of a file are terminated by CR, CRLF, or NEL, instead 130If the lines of a file are terminated by CR, CRLF, or NEL, instead
131of the Unix-standard LF, this will be reported. 131of the Unix-standard LF, this will be reported.
132Files that contain embedded escape sequences or overstriking 132Files that contain embedded escape sequences or overstriking
133will also be identified. 133will also be identified.
134.Pp 134.Pp
135Once 135Once
136.Nm 136.Nm
137has determined the character set used in a text-type file, 137has determined the character set used in a text-type file,
138it will 138it will
139attempt to determine in what language the file is written. 139attempt to determine in what language the file is written.
140The language tests look for particular strings (cf. 140The language tests look for particular strings (cf.
141.In names.h 141.In names.h
142) that can appear anywhere in the first few blocks of a file. 142) that can appear anywhere in the first few blocks of a file.
143For example, the keyword 143For example, the keyword
144.Em .br 144.Em .br
145indicates that the file is most likely a 145indicates that the file is most likely a
146.Xr troff 1 146.Xr troff 1
147input file, just as the keyword  147input file, just as the keyword
148.Em struct 148.Em struct
149indicates a C program. 149indicates a C program.
150These tests are less reliable than the previous 150These tests are less reliable than the previous
151two groups, so they are performed last. 151two groups, so they are performed last.
152The language test routines also test for some miscellany 152The language test routines also test for some miscellany
153(such as  153(such as
154.Xr tar 1 154.Xr tar 1
155archives). 155archives).
156.Pp 156.Pp
157Any file that cannot be identified as having been written 157Any file that cannot be identified as having been written
158in any of the character sets listed above is simply said to be 158in any of the character sets listed above is simply said to be
159.Dq data . 159.Dq data .
160.Sh OPTIONS 160.Sh OPTIONS
161.Bl -tag -width indent 161.Bl -tag -width indent
162.It Fl b , -brief 162.It Fl b , -brief
163Do not prepend filenames to output lines (brief mode). 163Do not prepend filenames to output lines (brief mode).
164.It Fl c , -checking-printout 164.It Fl c , -checking-printout
165Cause a checking printout of the parsed form of the magic file. 165Cause a checking printout of the parsed form of the magic file.
166This is usually used in conjunction with the 166This is usually used in conjunction with the
167.Fl m 167.Fl m
168flag to debug a new magic file before installing it. 168flag to debug a new magic file before installing it.
169.It Fl C , -compile 169.It Fl C , -compile
170Write a 170Write a
171.Pa magic.mgc 171.Pa magic.mgc
172output file that contains a pre-parsed version of the magic file or directory. 172output file that contains a pre-parsed version of the magic file or directory.
173.It Fl e , -exclude Ar testname 173.It Fl e , -exclude Ar testname
174Exclude the test named in 174Exclude the test named in
175.Ar testname 175.Ar testname
176from the list of tests made to determine the file type. Valid test names 176from the list of tests made to determine the file type. Valid test names
177are: 177are:
178.Bl -tag -width 178.Bl -tag -width compress
179.It apptype 179.It apptype
180Check for 180Check for
181.Dv EMX 181.Dv EMX
182application type (only on EMX). 182application type (only on EMX).
183.It ascii 183.It ascii
184Check for various types of ascii files. 184Check for various types of ascii files.
185.It compress 185.It compress
186Don't look for, or inside compressed files. 186Don't look for, or inside compressed files.
187.It elf 187.It elf
188Don't print elf details. 188Don't print elf details.
189.It fortran 189.It fortran
190Don't look for fortran sequences inside ascii files. 190Don't look for fortran sequences inside ascii files.
191.It soft 191.It soft
192Don't consult magic files. 192Don't consult magic files.
193.It tar 193.It tar
194Don't examine tar files. 194Don't examine tar files.
195.It token 195.It token
196Don't look for known tokens inside ascii files. 196Don't look for known tokens inside ascii files.
197.It troff 197.It troff
198Don't look for troff sequences inside ascii files. 198Don't look for troff sequences inside ascii files.
199.El 199.El
200.It Fl f , -files-from Ar namefile 200.It Fl f , -files-from Ar namefile
201Read the names of the files to be examined from  201Read the names of the files to be examined from
202.Ar namefile 202.Ar namefile
203(one per line)  203(one per line)
204before the argument list. 204before the argument list.
205Either  205Either
206.Ar namefile 206.Ar namefile
207or at least one filename argument must be present; 207or at least one filename argument must be present;
208to test the standard input, use  208to test the standard input, use
209.Sq - 209.Sq -
210as a filename argument. 210as a filename argument.
211.It Fl F , -separator Ar separator 211.It Fl F , -separator Ar separator
212Use the specified string as the separator between the filename and the 212Use the specified string as the separator between the filename and the
213file result returned. Defaults to  213file result returned. Defaults to
214.Sq \&: . 214.Sq \&: .
215.It Fl h , -no-dereference 215.It Fl h , -no-dereference
216option causes symlinks not to be followed 216option causes symlinks not to be followed
217(on systems that support symbolic links). This is the default if the 217(on systems that support symbolic links). This is the default if the
218environment variable 218environment variable
219.Dv POSIXLY_CORRECT 219.Dv POSIXLY_CORRECT
220is not defined. 220is not defined.
221.It Fl i , -mime 221.It Fl i , -mime
222Causes the file command to output mime type strings rather than the more 222Causes the file command to output mime type strings rather than the more
223traditional human readable ones. Thus it may say 223traditional human readable ones. Thus it may say
224.Dq text/plain charset=us-ascii 224.Dq text/plain charset=us-ascii
225rather than 225rather than
226.Dq ASCII text . 226.Dq ASCII text .
227In order for this option to work, file changes the way 227In order for this option to work, file changes the way
228it handles files recognized by the command itself (such as many of the 228it handles files recognized by the command itself (such as many of the
229text file types, directories etc), and makes use of an alternative 229text file types, directories etc), and makes use of an alternative
230.Dq magic 230.Dq magic
231file. 231file.
232(See 232(See
233.Dq FILES 233.Dq FILES
234section, below). 234section, below).
235.It Fl -mime-type , -mime-encoding 235.It Fl -mime-type , -mime-encoding
236Like 236Like
237.Fl i , 237.Fl i ,
238but print only the specified element(s). 238but print only the specified element(s).
239.It Fl k , -keep-going 239.It Fl k , -keep-going
240Don't stop at the first match, keep going. Subsequent matches will be 240Don't stop at the first match, keep going. Subsequent matches will be
241have the string 241have the string
242.Dq "\[rs]012\- " 242.Dq "\[rs]012\- "
243prepended. 243prepended.
244(If you want a newline, see the 244(If you want a newline, see the
245.Dq "\-r" 245.Dq "\-r"
246option.) 246option.)
247.It Fl L , -dereference 247.It Fl L , -dereference
248option causes symlinks to be followed, as the like-named option in 248option causes symlinks to be followed, as the like-named option in
249.Xr ls 1 249.Xr ls 1
250(on systems that support symbolic links). 250(on systems that support symbolic links).
251This is the default if the environment variable 251This is the default if the environment variable
252.Dv POSIXLY_CORRECT 252.Dv POSIXLY_CORRECT
253is defined. 253is defined.
254.It Fl m , -magic-file Ar list 254.It Fl m , -magic-file Ar list
255Specify an alternate list of files and directories containing magic. 255Specify an alternate list of files and directories containing magic.
256This can be a single item, or a colon-separated list. 256This can be a single item, or a colon-separated list.
257If a compiled magic file is found alongside a file or directory, it will be used instead. 257If a compiled magic file is found alongside a file or directory, it will be used instead.
258.It Fl n , -no-buffer 258.It Fl n , -no-buffer
259Force stdout to be flushed after checking each file. 259Force stdout to be flushed after checking each file.
260This is only useful if checking a list of files. 260This is only useful if checking a list of files.
261It is intended to be used by programs that want filetype output from a pipe. 261It is intended to be used by programs that want filetype output from a pipe.
262.It Fl N , -no-pad 262.It Fl N , -no-pad
263Don't pad filenames so that they align in the output. 263Don't pad filenames so that they align in the output.
264.It Fl p , -preserve-date 264.It Fl p , -preserve-date
265On systems that support 265On systems that support
266.Xr utime 2 266.Xr utime 2
267or 267or
268.Xr utimes 2 , 268.Xr utimes 2 ,
269attempt to preserve the access time of files analyzed, to pretend that 269attempt to preserve the access time of files analyzed, to pretend that
270.Nm 270.Nm
271never read them. 271never read them.
272.It Fl r , -raw 272.It Fl r , -raw
273Don't translate unprintable characters to \eooo. 273Don't translate unprintable characters to \eooo.
274Normally 274Normally
275.Nm 275.Nm
276translates unprintable characters to their octal representation. 276translates unprintable characters to their octal representation.
277.It Fl s , -special-files 277.It Fl s , -special-files
278Normally, 278Normally,
279.Nm 279.Nm
280only attempts to read and determine the type of argument files which 280only attempts to read and determine the type of argument files which
281.Xr stat 2 281.Xr stat 2
282reports are ordinary files. 282reports are ordinary files.
283This prevents problems, because reading special files may have peculiar 283This prevents problems, because reading special files may have peculiar
284consequences. 284consequences.
285Specifying the 285Specifying the
286.Fl s 286.Fl s
287option causes 287option causes
288.Nm 288.Nm
289to also read argument files which are block or character special files. 289to also read argument files which are block or character special files.
290This is useful for determining the filesystem types of the data in raw 290This is useful for determining the filesystem types of the data in raw
291disk partitions, which are block special files. 291disk partitions, which are block special files.
292This option also causes 292This option also causes
293.Nm 293.Nm
294to disregard the file size as reported by 294to disregard the file size as reported by
295.Xr stat 2 295.Xr stat 2
296since on some systems it reports a zero size for raw disk partitions. 296since on some systems it reports a zero size for raw disk partitions.
297.It Fl v , -version 297.It Fl v , -version
298Print the version of the program and exit. 298Print the version of the program and exit.
299.It Fl z , -uncompress 299.It Fl z , -uncompress
300Try to look inside compressed files. 300Try to look inside compressed files.
301.It Fl 0 , -print0 301.It Fl 0 , -print0
302Output a null character 302Output a null character
303.Sq \e0 303.Sq \e0
304after the end of the filename. Nice to 304after the end of the filename. Nice to
305.Xr cut 1 305.Xr cut 1
306the output. This does not affect the separator which is still printed. 306the output. This does not affect the separator which is still printed.
307.It Fl -help 307.It Fl -help
308Print a help message and exit. 308Print a help message and exit.
309.El 309.El
310.Sh FILES 310.Sh FILES
311.Bl -tag -width /usr/tools/share/file/magic.mgc -compact 311.Bl -tag -width /usr/tools/share/file/magic.mgc -compact
312.It Pa /usr/tools/share/file/magic.mgc 312.It Pa /usr/tools/share/file/magic.mgc
313Default compiled list of magic. 313Default compiled list of magic.
314.It Pa /usr/tools/share/file/magic 314.It Pa /usr/tools/share/file/magic
315Directory containing default magic files. 315Directory containing default magic files.
316.El 316.El
317.Sh ENVIRONMENT 317.Sh ENVIRONMENT
318The environment variable 318The environment variable
319.Dv MAGIC 319.Dv MAGIC
320can be used to set the default magic file name. 320can be used to set the default magic file name.
321If that variable is set, then 321If that variable is set, then
322.Nm 322.Nm
323will not attempt to open 323will not attempt to open
324.Pa $HOME/.magic . 324.Pa $HOME/.magic .
325.Nm 325.Nm
326adds 326adds
327.Dq .mgc 327.Dq .mgc
328to the value of this variable as appropriate. 328to the value of this variable as appropriate.
329The environment variable 329The environment variable
330.Dv POSIXLY_CORRECT 330.Dv POSIXLY_CORRECT
331controls (on systems that support symbolic links), whether 331controls (on systems that support symbolic links), whether
332.Nm 332.Nm
333will attempt to follow symlinks or not. If set, then 333will attempt to follow symlinks or not. If set, then
334.Nm 334.Nm
335follows symlink, otherwise it does not. This is also controlled 335follows symlink, otherwise it does not. This is also controlled
336by the 336by the
337.Fl L 337.Fl L
338and 338and
339.Fl h 339.Fl h
340options. 340options.
341.Sh SEE ALSO 341.Sh SEE ALSO
342.Xr magic 4 , 342.Xr magic 4 ,
343.Xr strings 1 , 343.Xr strings 1 ,
344.Xr od 1 , 344.Xr od 1 ,
345.Xr hexdump 1, 345.Xr hexdump 1,
346.Xr file 1posix 346.Xr file 1posix
347.Sh STANDARDS CONFORMANCE 347.Sh STANDARDS CONFORMANCE
348This program is believed to exceed the System V Interface Definition 348This program is believed to exceed the System V Interface Definition
349of FILE(CMD), as near as one can determine from the vague language 349of FILE(CMD), as near as one can determine from the vague language
350contained therein.  350contained therein.
351Its behavior is mostly compatible with the System V program of the same name. 351Its behavior is mostly compatible with the System V program of the same name.
352This version knows more magic, however, so it will produce 352This version knows more magic, however, so it will produce
353different (albeit more accurate) output in many cases.  353different (albeit more accurate) output in many cases.
354.\" URL: http://www.opengroup.org/onlinepubs/009695399/utilities/file.html 354.\" URL: http://www.opengroup.org/onlinepubs/009695399/utilities/file.html
355.Pp 355.Pp
356The one significant difference  356The one significant difference
357between this version and System V 357between this version and System V
358is that this version treats any white space 358is that this version treats any white space
359as a delimiter, so that spaces in pattern strings must be escaped. 359as a delimiter, so that spaces in pattern strings must be escaped.
360For example, 360For example,
361.Bd -literal -offset indent  361.Bd -literal -offset indent
362>10 string language impress\ (imPRESS data) 362>10 string language impress\ (imPRESS data)
363.Ed 363.Ed
364.Pp 364.Pp
365in an existing magic file would have to be changed to 365in an existing magic file would have to be changed to
366.Bd -literal -offset indent  366.Bd -literal -offset indent
367>10 string language\e impress (imPRESS data) 367>10 string language\e impress (imPRESS data)
368.Ed 368.Ed
369.Pp 369.Pp
370In addition, in this version, if a pattern string contains a backslash, 370In addition, in this version, if a pattern string contains a backslash,
371it must be escaped. 371it must be escaped.
372For example 372For example
373.Bd -literal -offset indent  373.Bd -literal -offset indent
3740 string \ebegindata Andrew Toolkit document 3740 string \ebegindata Andrew Toolkit document
375.Ed 375.Ed
376.Pp 376.Pp
377in an existing magic file would have to be changed to 377in an existing magic file would have to be changed to
378.Bd -literal -offset indent  378.Bd -literal -offset indent
3790 string \e\ebegindata Andrew Toolkit document 3790 string \e\ebegindata Andrew Toolkit document
380.Ed 380.Ed
381.Pp 381.Pp
382SunOS releases 3.2 and later from Sun Microsystems include a 382SunOS releases 3.2 and later from Sun Microsystems include a
383.Nm  383.Nm
384command derived from the System V one, but with some extensions. 384command derived from the System V one, but with some extensions.
385My version differs from Sun's only in minor ways. 385My version differs from Sun's only in minor ways.
386It includes the extension of the  386It includes the extension of the
387.Sq & 387.Sq &
388operator, used as, 388operator, used as,
389for example, 389for example,
390.Bd -literal -offset indent  390.Bd -literal -offset indent
391>16 long&0x7fffffff >0 not stripped 391>16 long&0x7fffffff >0 not stripped
392.Ed 392.Ed
393.Sh MAGIC DIRECTORY 393.Sh MAGIC DIRECTORY
394The magic file entries have been collected from various sources, 394The magic file entries have been collected from various sources,
395mainly USENET, and contributed by various authors. 395mainly USENET, and contributed by various authors.
396Christos Zoulas (address below) will collect additional 396Christos Zoulas (address below) will collect additional
397or corrected magic file entries. 397or corrected magic file entries.
398A consolidation of magic file entries  398A consolidation of magic file entries
399will be distributed periodically. 399will be distributed periodically.
400.Pp 400.Pp
401The order of entries in the magic file is significant. 401The order of entries in the magic file is significant.
402Depending on what system you are using, the order that 402Depending on what system you are using, the order that
403they are put together may be incorrect. 403they are put together may be incorrect.
404If your old 404If your old
405.Nm 405.Nm
406command uses a magic file, 406command uses a magic file,
407keep the old magic file around for comparison purposes 407keep the old magic file around for comparison purposes
408(rename it to  408(rename it to
409.Pa /usr/tools/share/file/magic.orig ). 409.Pa /usr/tools/share/file/magic.orig ).
410.Sh EXAMPLES 410.Sh EXAMPLES
411.Bd -literal -offset indent  411.Bd -literal -offset indent
412$ file file.c file /dev/{wd0a,hda} 412$ file file.c file /dev/{wd0a,hda}
413file.c: C program text 413file.c: C program text
414file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), 414file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
415 dynamically linked (uses shared libs), stripped 415 dynamically linked (uses shared libs), stripped
416/dev/wd0a: block special (0/0) 416/dev/wd0a: block special (0/0)
417/dev/hda: block special (3/0) 417/dev/hda: block special (3/0)
418 418
419$ file -s /dev/wd0{b,d} 419$ file -s /dev/wd0{b,d}
420/dev/wd0b: data 420/dev/wd0b: data
421/dev/wd0d: x86 boot sector 421/dev/wd0d: x86 boot sector
422 422
423$ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10} 423$ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
424/dev/hda: x86 boot sector 424/dev/hda: x86 boot sector
425/dev/hda1: Linux/i386 ext2 filesystem 425/dev/hda1: Linux/i386 ext2 filesystem
426/dev/hda2: x86 boot sector 426/dev/hda2: x86 boot sector
427/dev/hda3: x86 boot sector, extended partition table 427/dev/hda3: x86 boot sector, extended partition table
428/dev/hda4: Linux/i386 ext2 filesystem 428/dev/hda4: Linux/i386 ext2 filesystem
429/dev/hda5: Linux/i386 swap file 429/dev/hda5: Linux/i386 swap file
430/dev/hda6: Linux/i386 swap file 430/dev/hda6: Linux/i386 swap file
431/dev/hda7: Linux/i386 swap file 431/dev/hda7: Linux/i386 swap file
432/dev/hda8: Linux/i386 swap file 432/dev/hda8: Linux/i386 swap file
433/dev/hda9: empty 433/dev/hda9: empty
434/dev/hda10: empty 434/dev/hda10: empty
435 435
436$ file -i file.c file /dev/{wd0a,hda} 436$ file -i file.c file /dev/{wd0a,hda}
437file.c: text/x-c 437file.c: text/x-c
438file: application/x-executable 438file: application/x-executable
439/dev/hda: application/x-not-regular-file 439/dev/hda: application/x-not-regular-file
440/dev/wd0a: application/x-not-regular-file 440/dev/wd0a: application/x-not-regular-file
441 441
442.Ed 442.Ed
443.Sh HISTORY 443.Sh HISTORY
444There has been a  444There has been a
445.Nm  445.Nm
446command in every  446command in every
447.Dv UNIX since at least Research Version 4 447.Dv UNIX since at least Research Version 4
448(man page dated November, 1973). 448(man page dated November, 1973).
449The System V version introduced one significant major change: 449The System V version introduced one significant major change:
450the external list of magic types. 450the external list of magic types.
451This slowed the program down slightly but made it a lot more flexible. 451This slowed the program down slightly but made it a lot more flexible.
452.Pp 452.Pp
453This program, based on the System V version, 453This program, based on the System V version,
454was written by Ian Darwin <ian@darwinsys.com> 454was written by Ian Darwin <ian@darwinsys.com>
455without looking at anybody else's source code. 455without looking at anybody else's source code.
456.Pp 456.Pp
457John Gilmore revised the code extensively, making it better than 457John Gilmore revised the code extensively, making it better than
458the first version. 458the first version.
459Geoff Collyer found several inadequacies 459Geoff Collyer found several inadequacies
460and provided some magic file entries. 460and provided some magic file entries.
461Contributions by the `&' operator by Rob McMahon, cudcv@warwick.ac.uk, 1989. 461Contributions by the `&' operator by Rob McMahon, cudcv@warwick.ac.uk, 1989.
462.Pp 462.Pp
463Guy Harris, guy@netapp.com, made many changes from 1993 to the present. 463Guy Harris, guy@netapp.com, made many changes from 1993 to the present.
464.Pp 464.Pp
465Primary development and maintenance from 1990 to the present by 465Primary development and maintenance from 1990 to the present by
466Christos Zoulas (christos@astron.com). 466Christos Zoulas (christos@astron.com).
467.Pp 467.Pp
468Altered by Chris Lowth, chris@lowth.com, 2000: 468Altered by Chris Lowth, chris@lowth.com, 2000:
469Handle the  469Handle the
470.Fl i 470.Fl i
471option to output mime type strings, using an alternative 471option to output mime type strings, using an alternative
472magic file and internal logic. 472magic file and internal logic.
473.Pp 473.Pp
474Altered by Eric Fischer (enf@pobox.com), July, 2000, 474Altered by Eric Fischer (enf@pobox.com), July, 2000,
475to identify character codes and attempt to identify the languages 475to identify character codes and attempt to identify the languages
476of non-ASCII files. 476of non-ASCII files.
477.Pp 477.Pp
478Altered by Reuben Thomas (rrt@sc3d.org), 2007 to 2008, to improve MIME 478Altered by Reuben Thomas (rrt@sc3d.org), 2007 to 2008, to improve MIME
479support and merge MIME and non-MIME magic, support directories as well 479support and merge MIME and non-MIME magic, support directories as well
480as files of magic, apply many bug fixes and improve the build system. 480as files of magic, apply many bug fixes and improve the build system.
481.Pp 481.Pp
482The list of contributors to the 482The list of contributors to the
483.Dq magic 483.Dq magic
484directory (magic files) 484directory (magic files)
485is too long to include here. 485is too long to include here.
486You know who you are; thank you. 486You know who you are; thank you.
487Many contributors are listed in the source files. 487Many contributors are listed in the source files.
488.Sh LEGAL NOTICE 488.Sh LEGAL NOTICE
489Copyright (c) Ian F. Darwin, Toronto, Canada, 1986-1999. 489Copyright (c) Ian F. Darwin, Toronto, Canada, 1986-1999.
490Covered by the standard Berkeley Software Distribution copyright; see the file 490Covered by the standard Berkeley Software Distribution copyright; see the file
491LEGAL.NOTICE in the source distribution. 491LEGAL.NOTICE in the source distribution.
492.Pp 492.Pp
493The files 493The files
494.Dv tar.h 494.Dv tar.h
495and 495and
496.Dv is_tar.c 496.Dv is_tar.c
497were written by John Gilmore from his public-domain 497were written by John Gilmore from his public-domain
498.Xr tar 1 498.Xr tar 1
499program, and are not covered by the above license. 499program, and are not covered by the above license.
500.Sh BUGS 500.Sh BUGS
501.Pp 501.Pp
502There must be a better way to automate the construction of the Magic 502There must be a better way to automate the construction of the Magic
503file from all the glop in Magdir. 503file from all the glop in Magdir.
504What is it? 504What is it?
505.Pp 505.Pp
506.Nm 506.Nm
507uses several algorithms that favor speed over accuracy, 507uses several algorithms that favor speed over accuracy,
508thus it can be misled about the contents of 508thus it can be misled about the contents of
509text 509text
510files. 510files.
511.Pp 511.Pp
512The support for text files (primarily for programming languages) 512The support for text files (primarily for programming languages)
513is simplistic, inefficient and requires recompilation to update. 513is simplistic, inefficient and requires recompilation to update.
514.Pp 514.Pp
515The list of keywords in  515The list of keywords in
516.Dv ascmagic 516.Dv ascmagic
517probably belongs in the Magic file. 517probably belongs in the Magic file.
518This could be done by using some keyword like  518This could be done by using some keyword like
519.Sq * 519.Sq *
520for the offset value. 520for the offset value.
521.Pp 521.Pp
522Complain about conflicts in the magic file entries. 522Complain about conflicts in the magic file entries.
523Make a rule that the magic entries sort based on file offset rather 523Make a rule that the magic entries sort based on file offset rather
524than position within the magic file? 524than position within the magic file?
525.Pp 525.Pp
526The program should provide a way to give an estimate  526The program should provide a way to give an estimate
527of  527of
528.Dq how good 528.Dq how good
529a guess is. 529a guess is.
530We end up removing guesses (e.g.  530We end up removing guesses (e.g.
531.Dq From\  531.Dq From\
532as first 5 chars of file) because 532as first 5 chars of file) because
533they are not as good as other guesses (e.g.  533they are not as good as other guesses (e.g.
534.Dq Newsgroups: 534.Dq Newsgroups:
535versus 535versus
536.Dq Return-Path: 536.Dq Return-Path:
537). 537).
538Still, if the others don't pan out, it should be possible to use the 538Still, if the others don't pan out, it should be possible to use the
539first guess.  539first guess.
540.Pp 540.Pp
541This manual page, and particularly this section, is too long. 541This manual page, and particularly this section, is too long.
542.Sh RETURN CODE 542.Sh RETURN CODE
543.Nm 543.Nm
544returns 0 on success, and non-zero on error. 544returns 0 on success, and non-zero on error.
545.Sh AVAILABILITY 545.Sh AVAILABILITY
546You can obtain the original author's latest version by anonymous FTP 546You can obtain the original author's latest version by anonymous FTP
547on 547on
548.Dv ftp.astron.com 548.Dv ftp.astron.com
549in the directory 549in the directory
550.Dv /pub/file/file-X.YZ.tar.gz 550.Dv /pub/file/file-X.YZ.tar.gz