Linux 命令 - file: 确定文件类型

命令格式

file [-bchikLNnprsvz0] [--apple] [--mime-encoding] [--mime-type] [-e testname] [-F separator] [-f namefile] [-m magicfiles] file ...

file -C [-m magicfiles]

file [--help]

 

命令参数

-b, --brief
  不输出文件名(简要模式)。

-L, --dereference
  直接显示符号连接所指向的文件的类型。

-v, --version
  打印版本信息。

-z, --uncompress
  试图查看压缩文件内部信息。

--help
  打印帮助信息。

 

实例

a) 查看文件 hello.sh、hello.ln 和 hello.zip 的类型。

[huey@huey-K42JE ~]$ file hello.sh hello.ln hello.zip 
hello.sh:  Bourne-Again shell script text executable
hello.ln:  symbolic link to `hello.sh'
hello.zip: Zip archive data, at least v1.0 to extract

b) 直接显示 hello.ln 所指向的文件的类型。

[huey@huey-K42JE ~]$ file -L hello.sh
hello.sh: Bourne-Again shell script text executable

c) 试图查看压缩文件 hello.zip 的内部信息。

[huey@huey-K42JE ~]$ file -z hello.zip 
hello.zip: Bourne-Again shell script text executable (Zip archive data, at least v1.0 to extract)

 

posted on 2015-09-30 14:17  huey2672  阅读(1084)  评论(0编辑  收藏  举报