file - the file type is determined

Overview

File [ -bcnsvzL ] [ -f named file] [ -m magic file] file ...

description

This manual page describes the 3.27 version of the file using the command. File command tries to check each parameter to determine the type of file There are three sets of checks carried out in the following order: file system check, magic number tests, and language check file system check the success of the output file type.

The type of output will generally contain a word in the following: text (document only ASCII characters, you can use ASCII read this file terminal, in order to ensure the reliability of the content), Executable saved (file is the result of a program compiled Some UNIX kernel or the kernel can be understood that other such documents), or data represent all other types of files (usually binary data or non-printed), but some common file formats (e.g., core file, the tar package), while also contains binary data, does not belong to this category to modify the / usr / share / magic or the program itself, the preserve THESE Keywords. when a file is `` text '' type, that this file readable file not like the Berkeley environment to do that - take `` shell commands text '' changed to `` shell script ''.

File system check is based on the stat on the analysis result of a call (2) of the system. The program analyzes the file is empty, or whether it is a special file for all file types that can be used in existing systems (such as sets interface files, dynamic link files, the file named pipes (FIFOs), etc.), as long as it is in a system header file sys / stat.h already defined, can be checked.

The magic number to check whether there is data to check a particular fixed format file. Examples of specifications such as binary executable files (compiled program) the a.out , the file format in standard include directories a.out.h file defined, may also be in exec.h definition. these files are saved in the file to start a special section near the location of a 'magic number', told through magic number UNIX operating system, this file is a binary executable file, and it contains other types magic number concept has been extended to the data file has the file of any file type associated with the same identifier may represent such a fixed position in the file information from these files may be magic file / usr / share / magic of reading.

If the file is ASCII file, File will attempt to check its language. Language examination in a few blocks to find the beginning of the file (anywhere) Are there special string (see names.h ) For example, the keyword .br pointed out that this file is possibly troff (1) input file, the keyword struct pointed out that this file is a C program. check the language as good as the first two groups to check reliable, so on the last execution. it is also used to check some of the mixed files (such as tar (1) archive document) and determines that the file is `ascii text 'type or of` data' type.

Options

-b
No output file name (brief mode).
-c
Check the printout of the analysis result of magic file. Often with -m used together, to debug it before installing magic file.
-f file name
From the prior parameter table named files read out to be checked the file name (one per line) and must name the file , or at least a file name argument; If you want to check the standard input, using the `` - '' as a file parameter.
-m list
The file containing the list of magic number may be a single file, multiple files may be separated by colons.
-n
After each inspection a file to force a refresh to the standard output. Only when checking a set of files is valid. In general the output file type to a pipe when using this option.
-v
Print program version and exit.
-with
Try to view compressed files inside information.
-L
(On systems that support symbolic links) option displays the original file the symbolic link file, as LS (1) like-named option command.
-s
Usually, file just trying to check the list of files that stat type (2) reported as normal files Since reading special files may lead to unknown consequences, so this problem can be prevented using the -s option file command will read the file list block special files and character special files are generally used to get from raw disk partition file system type, the file is a block special file. this option can also lead to file command to ignore the stat file (2) report size, because in some systems a raw disk partition size is reported as zero.

file

/ usr / report this content share / Magic - default list of magic number

ENVIRONMENT

Environment variable MAGIC is used to set the default magic file. 

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11082292.html