1*08ff44c4SLionel Sambuc.\" $NetBSD: file.1,v 1.9 2012/02/22 17:53:50 christos Exp $ 2ef01931fSBen Gras.\" 3*08ff44c4SLionel Sambuc.\" $File: file.man,v 1.98 2011/12/08 12:12:46 rrt Exp $ 4*08ff44c4SLionel Sambuc.Dd October 17, 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 12835f6802SDirk Vogt.Bk -words 13835f6802SDirk Vogt.Op Fl bchiklLNnprsvz0 14835f6802SDirk Vogt.Op Fl Fl apple 15835f6802SDirk Vogt.Op Fl Fl mime-encoding 16835f6802SDirk Vogt.Op Fl Fl mime-type 17835f6802SDirk 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 21835f6802SDirk Vogt.Ar 22835f6802SDirk Vogt.Ek 23ef01931fSBen Gras.Nm 24ef01931fSBen Gras.Fl C 25835f6802SDirk Vogt.Op Fl m Ar magicfiles 26ef01931fSBen Gras.Nm 27ef01931fSBen Gras.Op Fl Fl help 28ef01931fSBen Gras.Sh DESCRIPTION 29*08ff44c4SLionel SambucThis manual page documents version 5.11 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). 171835f6802SDirk Vogt.It Fl C , Fl Fl compile 172835f6802SDirk VogtWrite a 173835f6802SDirk Vogt.Pa magic.mgc 174835f6802SDirk 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). 189835f6802SDirk 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 192835f6802SDirk Vogt.Sq encoding 193ef01931fSBen Grasoption). 194ef01931fSBen Gras.It encoding 195ef01931fSBen GrasDifferent text encodings for soft magic tests. 196ef01931fSBen Gras.It tokens 197*08ff44c4SLionel SambucIgnored for backwards compatibility. 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. 225*08ff44c4SLionel SambucPlease note that 226*08ff44c4SLionel Sambuc.Ar namefile 227*08ff44c4SLionel Sambucis unwrapped and the enclosed filenames are processed when this option is 228*08ff44c4SLionel Sambucencountered and before any further options processing is done. 229*08ff44c4SLionel SambucThis allows one to process multiple lists of files with different command line 230*08ff44c4SLionel Sambucarguments on the same 231*08ff44c4SLionel Sambuc.Nm 232*08ff44c4SLionel Sambucinvocation. 233*08ff44c4SLionel SambucThus if you want to set the delimiter, you need to do it before you specify 234*08ff44c4SLionel Sambucthe list of files, like: 235*08ff44c4SLionel Sambuc.Dq Fl F Ar @ Fl f Ar namefile , 236*08ff44c4SLionel Sambucinstead of: 237*08ff44c4SLionel Sambuc.Dq Fl f Ar namefile Fl F Ar @ . 238ef01931fSBen Gras.It Fl h , Fl Fl no-dereference 239835f6802SDirk Vogtoption causes symlinks not to be followed 240ef01931fSBen Gras(on systems that support symbolic links). 241ef01931fSBen GrasThis is the default if the environment variable 242835f6802SDirk Vogt.Dv POSIXLY_CORRECT 243ef01931fSBen Grasis not defined. 244ef01931fSBen Gras.It Fl i , Fl Fl mime 245835f6802SDirk VogtCauses the file command to output mime type strings rather than the more 246ef01931fSBen Grastraditional human readable ones. 247835f6802SDirk VogtThus it may say 248835f6802SDirk Vogt.Sq text/plain; charset=us-ascii 249ef01931fSBen Grasrather than 250ef01931fSBen Gras.Dq ASCII text . 251ef01931fSBen Gras.It Fl Fl mime-type , Fl Fl mime-encoding 252ef01931fSBen GrasLike 253ef01931fSBen Gras.Fl i , 254ef01931fSBen Grasbut print only the specified element(s). 255ef01931fSBen Gras.It Fl k , Fl Fl keep-going 256ef01931fSBen GrasDon't stop at the first match, keep going. 257835f6802SDirk VogtSubsequent matches will be 258835f6802SDirk Vogthave the string 259835f6802SDirk Vogt.Sq "\[rs]012\- " 260ef01931fSBen Grasprepended. 261ef01931fSBen Gras(If you want a newline, see the 262ef01931fSBen Gras.Fl r 263ef01931fSBen Grasoption.) 264835f6802SDirk Vogt.It Fl l , Fl Fl list 265835f6802SDirk VogtPrint information about the strength of each magic pattern. 266ef01931fSBen Gras.It Fl L , Fl Fl dereference 267835f6802SDirk Vogtoption causes symlinks to be followed, as the like-named option in 268ef01931fSBen Gras.Xr ls 1 269ef01931fSBen Gras(on systems that support symbolic links). 270ef01931fSBen GrasThis is the default if the environment variable 271ef01931fSBen Gras.Ev POSIXLY_CORRECT 272ef01931fSBen Grasis defined. 273835f6802SDirk Vogt.It Fl l 274835f6802SDirk VogtShows sorted patterns list in the order which is used for the matching. 275835f6802SDirk Vogt.It Fl m , Fl Fl magic-file Ar magicfiles 276ef01931fSBen GrasSpecify an alternate list of files and directories containing magic. 277ef01931fSBen GrasThis can be a single item, or a colon-separated list. 278ef01931fSBen GrasIf a compiled magic file is found alongside a file or directory, 279ef01931fSBen Grasit will be used instead. 280ef01931fSBen Gras.It Fl N , Fl Fl no-pad 281ef01931fSBen GrasDon't pad filenames so that they align in the output. 282ef01931fSBen Gras.It Fl n , Fl Fl no-buffer 283ef01931fSBen GrasForce stdout to be flushed after checking each file. 284ef01931fSBen GrasThis is only useful if checking a list of files. 285ef01931fSBen GrasIt is intended to be used by programs that want filetype output from a pipe. 286ef01931fSBen Gras.It Fl p , Fl Fl preserve-date 287ef01931fSBen GrasOn systems that support 288ef01931fSBen Gras.Xr utime 3 289ef01931fSBen Grasor 290ef01931fSBen Gras.Xr utimes 2 , 291ef01931fSBen Grasattempt to preserve the access time of files analyzed, to pretend that 292ef01931fSBen Gras.Nm 293ef01931fSBen Grasnever read them. 294ef01931fSBen Gras.It Fl r , Fl Fl raw 295ef01931fSBen GrasDon't translate unprintable characters to \eooo. 296ef01931fSBen GrasNormally 297ef01931fSBen Gras.Nm 298ef01931fSBen Grastranslates unprintable characters to their octal representation. 299ef01931fSBen Gras.It Fl s , Fl Fl special-files 300ef01931fSBen GrasNormally, 301ef01931fSBen Gras.Nm 302ef01931fSBen Grasonly attempts to read and determine the type of argument files which 303ef01931fSBen Gras.Xr stat 2 304ef01931fSBen Grasreports are ordinary files. 305ef01931fSBen GrasThis prevents problems, because reading special files may have peculiar 306ef01931fSBen Grasconsequences. 307ef01931fSBen GrasSpecifying the 308ef01931fSBen Gras.Fl s 309ef01931fSBen Grasoption causes 310ef01931fSBen Gras.Nm 311ef01931fSBen Grasto also read argument files which are block or character special files. 312ef01931fSBen GrasThis is useful for determining the filesystem types of the data in raw 313ef01931fSBen Grasdisk partitions, which are block special files. 314ef01931fSBen GrasThis option also causes 315ef01931fSBen Gras.Nm 316ef01931fSBen Grasto disregard the file size as reported by 317ef01931fSBen Gras.Xr stat 2 318ef01931fSBen Grassince on some systems it reports a zero size for raw disk partitions. 319ef01931fSBen Gras.It Fl v , Fl Fl version 320ef01931fSBen GrasPrint the version of the program and exit. 321ef01931fSBen Gras.It Fl z , Fl Fl uncompress 322ef01931fSBen GrasTry to look inside compressed files. 323835f6802SDirk Vogt.It Fl 0 , Fl Fl print0 324835f6802SDirk VogtOutput a null character 325835f6802SDirk Vogt.Sq \e0 326835f6802SDirk Vogtafter the end of the filename. 327835f6802SDirk VogtNice to 328835f6802SDirk Vogt.Xr cut 1 329835f6802SDirk Vogtthe output. 330835f6802SDirk VogtThis does not affect the separator which is still printed. 331835f6802SDirk Vogt.It Fl -help 332835f6802SDirk VogtPrint a help message and exit. 333835f6802SDirk Vogt.El 334835f6802SDirk Vogt.Sh FILES 335835f6802SDirk Vogt.Bl -tag -width /usr/share/misc/magic.mgc -compact 336835f6802SDirk Vogt.It Pa /usr/share/misc/magic.mgc 337835f6802SDirk VogtDefault compiled list of magic. 338835f6802SDirk Vogt.It Pa /usr/share/misc/magic 339835f6802SDirk VogtDirectory containing default magic files. 340ef01931fSBen Gras.El 341ef01931fSBen Gras.Sh ENVIRONMENT 342ef01931fSBen GrasThe environment variable 343ef01931fSBen Gras.Ev MAGIC 344ef01931fSBen Grascan be used to set the default magic file name. 345ef01931fSBen GrasIf that variable is set, then 346ef01931fSBen Gras.Nm 347ef01931fSBen Graswill not attempt to open 348ef01931fSBen Gras.Pa $HOME/.magic . 349ef01931fSBen Gras.Nm 350ef01931fSBen Grasadds 351ef01931fSBen Gras.Dq Pa .mgc 352ef01931fSBen Grasto the value of this variable as appropriate. 353835f6802SDirk VogtHowever, 354835f6802SDirk Vogt.Pa file 355835f6802SDirk Vogthas to exist in order for 356835f6802SDirk Vogt.Pa file.mime 357835f6802SDirk Vogtto be considered. 358ef01931fSBen GrasThe environment variable 359ef01931fSBen Gras.Ev POSIXLY_CORRECT 360ef01931fSBen Grascontrols (on systems that support symbolic links), whether 361ef01931fSBen Gras.Nm 362ef01931fSBen Graswill attempt to follow symlinks or not. 363ef01931fSBen GrasIf set, then 364ef01931fSBen Gras.Nm 365ef01931fSBen Grasfollows symlink, otherwise it does not. 366ef01931fSBen GrasThis is also controlled by the 367ef01931fSBen Gras.Fl L 368ef01931fSBen Grasand 369ef01931fSBen Gras.Fl h 370ef01931fSBen Grasoptions. 371ef01931fSBen Gras.Sh SEE ALSO 372835f6802SDirk Vogt.Xr magic 5 , 373ef01931fSBen Gras.Xr hexdump 1 , 374ef01931fSBen Gras.Xr od 1 , 375ef01931fSBen Gras.Xr strings 1 , 376835f6802SDirk Vogt.Sh STANDARDS CONFORMANCE 377ef01931fSBen GrasThis program is believed to exceed the System V Interface Definition 378ef01931fSBen Grasof FILE(CMD), as near as one can determine from the vague language 379ef01931fSBen Grascontained therein. 380ef01931fSBen GrasIts behavior is mostly compatible with the System V program of the same name. 381ef01931fSBen GrasThis version knows more magic, however, so it will produce 382ef01931fSBen Grasdifferent (albeit more accurate) output in many cases. 383ef01931fSBen Gras.\" URL: http://www.opengroup.org/onlinepubs/009695399/utilities/file.html 384ef01931fSBen Gras.Pp 385ef01931fSBen GrasThe one significant difference 386ef01931fSBen Grasbetween this version and System V 387ef01931fSBen Grasis that this version treats any white space 388ef01931fSBen Grasas a delimiter, so that spaces in pattern strings must be escaped. 389ef01931fSBen GrasFor example, 390ef01931fSBen Gras.Bd -literal -offset indent 391ef01931fSBen Gras\*[Gt]10 string language impress\ (imPRESS data) 392ef01931fSBen Gras.Ed 393ef01931fSBen Gras.Pp 394ef01931fSBen Grasin an existing magic file would have to be changed to 395ef01931fSBen Gras.Bd -literal -offset indent 396ef01931fSBen Gras\*[Gt]10 string language\e impress (imPRESS data) 397ef01931fSBen Gras.Ed 398ef01931fSBen Gras.Pp 399ef01931fSBen GrasIn addition, in this version, if a pattern string contains a backslash, 400ef01931fSBen Grasit must be escaped. 401ef01931fSBen GrasFor example 402ef01931fSBen Gras.Bd -literal -offset indent 403ef01931fSBen Gras0 string \ebegindata Andrew Toolkit document 404ef01931fSBen Gras.Ed 405ef01931fSBen Gras.Pp 406ef01931fSBen Grasin an existing magic file would have to be changed to 407ef01931fSBen Gras.Bd -literal -offset indent 408ef01931fSBen Gras0 string \e\ebegindata Andrew Toolkit document 409ef01931fSBen Gras.Ed 410ef01931fSBen Gras.Pp 411ef01931fSBen GrasSunOS releases 3.2 and later from Sun Microsystems include a 412ef01931fSBen Gras.Nm 413ef01931fSBen Grascommand derived from the System V one, but with some extensions. 414ef01931fSBen GrasThis version differs from Sun's only in minor ways. 415ef01931fSBen GrasIt includes the extension of the 416ef01931fSBen Gras.Sq \*[Am] 417ef01931fSBen Grasoperator, used as, 418ef01931fSBen Grasfor example, 419ef01931fSBen Gras.Bd -literal -offset indent 420ef01931fSBen Gras\*[Gt]16 long\*[Am]0x7fffffff \*[Gt]0 not stripped 421ef01931fSBen Gras.Ed 422ef01931fSBen Gras.Sh MAGIC DIRECTORY 423ef01931fSBen GrasThe magic file entries have been collected from various sources, 424ef01931fSBen Grasmainly USENET, and contributed by various authors. 425ef01931fSBen GrasChristos Zoulas (address below) will collect additional 426ef01931fSBen Grasor corrected magic file entries. 427ef01931fSBen GrasA consolidation of magic file entries 428ef01931fSBen Graswill be distributed periodically. 429ef01931fSBen Gras.Pp 430ef01931fSBen GrasThe order of entries in the magic file is significant. 431ef01931fSBen GrasDepending on what system you are using, the order that 432ef01931fSBen Grasthey are put together may be incorrect. 433ef01931fSBen GrasIf your old 434ef01931fSBen Gras.Nm 435ef01931fSBen Grascommand uses a magic file, 436ef01931fSBen Graskeep the old magic file around for comparison purposes 437ef01931fSBen Gras(rename it to 438ef01931fSBen Gras.Pa /usr/share/misc/magic.orig ) . 439835f6802SDirk Vogt.Sh EXAMPLES 440835f6802SDirk Vogt.Bd -literal -offset indent 441835f6802SDirk Vogt$ file file.c file /dev/{wd0a,hda} 442835f6802SDirk Vogtfile.c: C program text 443835f6802SDirk Vogtfile: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), 444835f6802SDirk Vogt dynamically linked (uses shared libs), stripped 445835f6802SDirk Vogt/dev/wd0a: block special (0/0) 446835f6802SDirk Vogt/dev/hda: block special (3/0) 447835f6802SDirk Vogt 448835f6802SDirk Vogt$ file -s /dev/wd0{b,d} 449835f6802SDirk Vogt/dev/wd0b: data 450835f6802SDirk Vogt/dev/wd0d: x86 boot sector 451835f6802SDirk Vogt 452835f6802SDirk Vogt$ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10} 453835f6802SDirk Vogt/dev/hda: x86 boot sector 454835f6802SDirk Vogt/dev/hda1: Linux/i386 ext2 filesystem 455835f6802SDirk Vogt/dev/hda2: x86 boot sector 456835f6802SDirk Vogt/dev/hda3: x86 boot sector, extended partition table 457835f6802SDirk Vogt/dev/hda4: Linux/i386 ext2 filesystem 458835f6802SDirk Vogt/dev/hda5: Linux/i386 swap file 459835f6802SDirk Vogt/dev/hda6: Linux/i386 swap file 460835f6802SDirk Vogt/dev/hda7: Linux/i386 swap file 461835f6802SDirk Vogt/dev/hda8: Linux/i386 swap file 462835f6802SDirk Vogt/dev/hda9: empty 463835f6802SDirk Vogt/dev/hda10: empty 464835f6802SDirk Vogt 465835f6802SDirk Vogt$ file -i file.c file /dev/{wd0a,hda} 466835f6802SDirk Vogtfile.c: text/x-c 467835f6802SDirk Vogtfile: application/x-executable 468835f6802SDirk Vogt/dev/hda: application/x-not-regular-file 469835f6802SDirk Vogt/dev/wd0a: application/x-not-regular-file 470835f6802SDirk Vogt 471835f6802SDirk Vogt.Ed 472ef01931fSBen Gras.Sh HISTORY 473ef01931fSBen GrasThere has been a 474ef01931fSBen Gras.Nm 475ef01931fSBen Grascommand in every 476ef01931fSBen Gras.Dv UNIX since at least Research Version 4 477ef01931fSBen Gras(man page dated November, 1973). 478ef01931fSBen GrasThe System V version introduced one significant major change: 479ef01931fSBen Grasthe external list of magic types. 480ef01931fSBen GrasThis slowed the program down slightly but made it a lot more flexible. 481ef01931fSBen Gras.Pp 482ef01931fSBen GrasThis program, based on the System V version, 483ef01931fSBen Graswas written by Ian Darwin 484ef01931fSBen Gras.Aq ian@darwinsys.com 485ef01931fSBen Graswithout looking at anybody else's source code. 486ef01931fSBen Gras.Pp 487ef01931fSBen GrasJohn Gilmore revised the code extensively, making it better than 488ef01931fSBen Grasthe first version. 489ef01931fSBen GrasGeoff Collyer found several inadequacies 490ef01931fSBen Grasand provided some magic file entries. 491ef01931fSBen GrasContributions by the 492ef01931fSBen Gras.Sq \*[Am] 493835f6802SDirk Vogtoperator by Rob McMahon, 494835f6802SDirk Vogt.Aq cudcv@warwick.ac.uk , 495835f6802SDirk Vogt1989. 496ef01931fSBen Gras.Pp 497835f6802SDirk VogtGuy Harris, 498835f6802SDirk Vogt.Aq guy@netapp.com , 499835f6802SDirk Vogtmade many changes from 1993 to the present. 500835f6802SDirk Vogt1989. 501ef01931fSBen Gras.Pp 502ef01931fSBen GrasPrimary development and maintenance from 1990 to the present by 503ef01931fSBen GrasChristos Zoulas 504ef01931fSBen Gras.Aq christos@astron.com . 505ef01931fSBen Gras.Pp 506835f6802SDirk VogtAltered by Chris Lowth 507835f6802SDirk Vogt.Aq chris@lowth.com , 508835f6802SDirk Vogt2000: handle the 509ef01931fSBen Gras.Fl i 510ef01931fSBen Grasoption to output mime type strings, using an alternative 511ef01931fSBen Grasmagic file and internal logic. 512ef01931fSBen Gras.Pp 513ef01931fSBen GrasAltered by Eric Fischer 514ef01931fSBen Gras.Aq enf@pobox.com , 515ef01931fSBen GrasJuly, 2000, 516ef01931fSBen Grasto identify character codes and attempt to identify the languages 517ef01931fSBen Grasof non-ASCII files. 518ef01931fSBen Gras.Pp 519ef01931fSBen GrasAltered by Reuben Thomas 520ef01931fSBen Gras.Aq rrt@sc3d.org , 521835f6802SDirk Vogt2007-2011, to improve MIME support, merge MIME and non-MIME magic, 522835f6802SDirk Vogtsupport directories as well as files of magic, apply many bug fixes, 523835f6802SDirk Vogtupdate and fix a lot of magic, improve the build system, improve the 524835f6802SDirk Vogtdocumentation, and rewrite the Python bindings in pure Python. 525ef01931fSBen Gras.Pp 526ef01931fSBen GrasThe list of contributors to the 527ef01931fSBen Gras.Sq magic 528ef01931fSBen Grasdirectory (magic files) 529ef01931fSBen Grasis too long to include here. 530ef01931fSBen GrasYou know who you are; thank you. 531ef01931fSBen GrasMany contributors are listed in the source files. 532ef01931fSBen Gras.Sh LEGAL NOTICE 533ef01931fSBen GrasCopyright (c) Ian F. Darwin, Toronto, Canada, 1986-1999. 534ef01931fSBen GrasCovered by the standard Berkeley Software Distribution copyright; see the file 535835f6802SDirk VogtCOPYING in the source distribution. 536ef01931fSBen Gras.Pp 537ef01931fSBen GrasThe files 538ef01931fSBen Gras.Pa tar.h 539ef01931fSBen Grasand 540ef01931fSBen Gras.Pa is_tar.c 541ef01931fSBen Graswere written by John Gilmore from his public-domain 542ef01931fSBen Gras.Xr tar 1 543ef01931fSBen Grasprogram, and are not covered by the above license. 544835f6802SDirk Vogt.Sh RETURN CODE 545ef01931fSBen Gras.Nm 546835f6802SDirk Vogtreturns 0 on success, and non-zero on error. 547835f6802SDirk Vogt.Sh BUGS 548ef01931fSBen Gras.Pp 549835f6802SDirk VogtPlease report bugs and send patches to the bug tracker at 550835f6802SDirk Vogt.Pa http://bugs.gw.com/ 551835f6802SDirk Vogtor the mailing list at 552835f6802SDirk Vogt.Aq file@mx.gw.com . 553835f6802SDirk Vogt.Sh TODO 554ef01931fSBen Gras.Pp 555835f6802SDirk VogtFix output so that tests for MIME and APPLE flags are not needed all 556835f6802SDirk Vogtover the place, and actual output is only done in one place. This 557835f6802SDirk Vogtneeds a design. Suggestion: push possible outputs on to a list, then 558835f6802SDirk Vogtpick the last-pushed (most specific, one hopes) value at the end, or 559835f6802SDirk Vogtuse a default if the list is empty. This should not slow down evaluation. 560ef01931fSBen Gras.Pp 561835f6802SDirk VogtContinue to squash all magic bugs. See Debian BTS for a good source. 562ef01931fSBen Gras.Pp 563835f6802SDirk VogtStore arbitrarily long strings, for example for %s patterns, so that 564835f6802SDirk Vogtthey can be printed out. Fixes Debian bug #271672. Would require more 565835f6802SDirk Vogtcomplex store/load code in apprentice. 566ef01931fSBen Gras.Pp 567835f6802SDirk VogtAdd syntax for relative offsets after current level (Debian bug #466037). 568835f6802SDirk Vogt.Pp 569835f6802SDirk VogtMake file -ki work, i.e. give multiple MIME types. 570835f6802SDirk Vogt.Pp 571835f6802SDirk VogtAdd a zip library so we can peek inside Office2007 documents to 572835f6802SDirk Vogtfigure out what they are. 573835f6802SDirk Vogt.Pp 574835f6802SDirk VogtAdd an option to print URLs for the sources of the file descriptions. 575ef01931fSBen Gras.Sh AVAILABILITY 576ef01931fSBen GrasYou can obtain the original author's latest version by anonymous FTP 577ef01931fSBen Grason 578ef01931fSBen Gras.Pa ftp.astron.com 579ef01931fSBen Grasin the directory 580ef01931fSBen Gras.Pa /pub/file/file-X.YZ.tar.gz . 581