SYNOPSIS
file [
DESCRIPTION
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.
- Note:
-
Symbolic links are only available on 8.1/2012R2/2016/2019/2022 systems with the NTFS file system.
Options
-c -
only 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 filelist-
examines the files listed in the file filelist.
-h -
identifies symbolic links as symbolic links. Normally, file reports the file type of the file to which the link refers.
- Note:
-
Symbolic links are only available on 8.1/2012R2/2016/2019/2022 systems with the NTFS file system.
-m magic-
uses the file magic rather than the default file of file-type templates.
ENVIRONMENT VARIABLES
- MAGIC
-
when set, specifies a template file of magic numbers to use instead of ROOTDIR/etc/magic. The
-m overrides the setting of this environment variable.
FILES
- ROOTDIR/etc/magic
-
default template file of magic numbers. The ROOTDIR environment variable is described in envvar.
DIAGNOSTICS
Possible exit status values are:
- 0
-
Successful completion. If a specified file does not exist, it is not considered an error and file returns 0.
- 1
-
Failure due to any of the following:
- — a missing filelist after
-f - — more than one
-f option on the command line - — cannot find the magic file
- — invalid command line option
- — too few command line arguments
- — cannot access a specified file
- — cannot open filelist
- — cannot open the magic file
- — a format error in the magic file
- — out of memory for reading or magic entries
- — a bad number in the magic file
- — a misplaced > in the magic file
- — a missing filelist after
- 2
-
A usage error occurred.
PORTABILITY
POSIX.2. x/OPEN Portability Guide 4.0. All UNIX systems. Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022.
All options are extensions to the POSIX standard.
AVAILABILITY
PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
- File Formats:
- magic
- Miscellaneous:
- envvar
PTC MKS Toolkit 10.4 Documentation Build 39.