filedetermine file type |
Command |
file [-c] [-f
filelist] [-m magic] file ...
file makes a guess at the type of each file argument
by inspecting the attributes and (for an ordinary file) reading an initial part
of the file. file compares each file on the command line to
templates found in a system-maintained magic file to determine their file
type.
file then divides files which do not match a template in the
magic file into text files and binary data. Then, by reading an initial
segment of the text files and making an informed guess based on the contents,
file further divides text files into various types such as:
C programs, assembler programs, files of commands to the shell, text with
nroff or other embedded formatting
commands, yacc or
lex programs.
file displays the name of each file and the file type it
believes the file to be. If a file is a symbolic link to another file,
file follows the link and reports the file type of the
resulting file. If the symbolic link refers to a nonexistent file,
file identifies the file as a symbolic link.
-conly checks the template file of magic numbers for validity of format. The magic numbers given in the template file describe particular types of files.
-f filelistexamines the files listed in the file filelist.
-hidentifies symbolic links as symbolic links. Normally,
file reports the file type of the file to which the
link refers.
-m magicuses the file magic rather than the default file of file-type templates.
/etc/magicdefault template file of magic numbers.
0Successful completion. If a specified file does not exist, it is
not considered an error and file returns
0.
1Failure due to any of the following:
-f-f option on the command linemagic filemagic filemagic filemagic entriesmagic file> in the magic file2A usage error occurred.
magic
envvar