首页

file

file
功能说明:辨识文件类型。 
语  法:file [-beLvz][-f <名称文件>][-m <魔法数字文件>...][文件或目录...]  
补充说明:通过file指令,我们得以辨识该文件的类型。 
参  数:
 -b  列出辨识结果时,不显示文件名称。 
 -c  详细显示指令执行过程,便于排错或分析程序执行的情形。 
 -f<名称文件>  指定名称文件,其内容有一个或多个文件名称呢感,让file依序辨识这些文件,格式为每列一个文件名称。  
 -L  直接显示符号连接所指向的文件的类别。 
 -m<魔法数字文件>  指定魔法数字文件。 
 -v  显示版本信息。 
 -z  尝试去解读压缩文件的内容。

file

file [options] files

Classify the named files according to the type of data they contain. file checks the magic file (usually /usr/share/magic) to identify some file types.

Options

-b

Brief mode; do not prepend filenames to output lines.

-c

Check the format of the magic file (files argument is invalid with -c). Usually used with -m.

-f file

Read the names of files to be checked from file.

-L

Follow symbolic links. By default, symbolic links are not followed.

-m file

Search for file types in file instead of /usr/share/magic.

-n

Flush standard output after checking a file.

-s

Check files that are block or character special files in addition to checking ordinary files.

-v

Print the version.

-z

Attempt checking of compressed files.

Many file types are understood. Output lists each filename, followed by a brief classification such as:

ascii text c program text c-shell commands data empty iAPX 386 executable directory [nt] roff, tbl, or eqn input text shell commands symbolic link to ../usr/etc/arp

Example

List all files that are deemed to be troff/nroff input:

file * | grep roff