FILE(1) COMMAND REFERENCE FILE(1) NAME file - determine file type SYNOPSIS file [ -c ] [ -f ffile ] [ -m mfile ] arg ... DESCRIPTION File performs a series of tests on each argument in an attempt to classify it. If an argument appears to be ASCII, file examines the first 512 bytes and tries to guess its language. Each file is printed in the format: name: file type Symbolic links are printed in the format: name: Symbolic link. File pointed to is <file type> File uses the file /usr/lib/magic to identify files that have some sort of magic number, that is, any file containing a numeric or string constant that indicates its type. The file format is described in the manual page magic(5). File recognizes the following file types: ASCII archive (long format) ASCII archive (normal format) ASCII cpio archive ASCII text Assembler program text BASIC keyed internal file BASIC program text BASIC relative internal file BASIC sequential internal file BASIC stream internal file Block special C program text Character special Commands text Compacted text Cpio archives Data Demand paged executable Directories English text FORTRAN program text MH message Nroff, troff, tbl, or eqn input Old archive Old executable Printed 5/12/88 1
FILE(1) COMMAND REFERENCE FILE(1) Packed text Program scripts pxl file RCS file Read only pure executable Symbol table information System V terminal capability file TeX font metric (tfm) file TeX output (dvi) Troff output If the file is executable and not stripped, that fact is noted. There are two ASCII archive formats: normal and long. In each case, if the archive contains a symbol definition table (see ar(1) and ranlib(1)), that fact is noted. A program script file is a file whose first line is an interpreter line (see execve(2)). The name of the program to be executed is printed. If an ASCII file contains characters with the eighth bit set, the file type is followed by the words ``with garbage''. OPTIONS -c Causes file to check the magic file (/usr/lib/magic) for format errors. This validation is not normally carried out for reasons of efficiency. No file typing is done under -c. -f ffile The next argument is taken to be a file containing the names of the files to be examined. -m mfile Instructs file to use an alternate magic file. EXAMPLES The following example will print the name of each file in /da/tmp followed by its classification. file /da/tmp/* RETURN VALUE [P_ERR] A system error occurred. Execution terminated. See intro(2) for more information on system errors. [NP_ERR] An error occurred that was not a system Printed 5/12/88 2
FILE(1) COMMAND REFERENCE FILE(1) error. Execution terminated. [NP_WARN] An error warranting a warning message occurred. Execution continues. [USAGE] Incorrect command line syntax. Execution terminated. [NO_ERRS] Command completed without error. CAVEATS It often makes mistakes. In particular it often suggests that command files are C programs. Does not recognize Pascal or LISP. Interpreter lines ('#! pathname') are not checked for validity. A line like '#! /foo' will cause the file to be identified as script commands for /foo, even though the file will not be executed. Execute permission is not checked. SEE ALSO ld(1), notmagic(3c), a.out(5), ar(5), cpio(5), magic(5), and rcsfile(5rcs). Printed 5/12/88 3
%%index%% na:240,78; sy:318,267; de:585,1784;2681,870; op:3551,682; ex:4233,235; rv:4468,356;5136,309; ca:5445,494; se:5939,279; %%index%%000000000152