LinuxEye - Linux系统教程

LinuxEye - Linux系统教程

当前位置: 主页 > Linux命令 >

Linux file命令参数及使用方法详解

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

使用示例
示例一:显示文件类型
[root@server1 linuxeye]# file linuxeye.com
linuxeye.com: ASCII text
[root@server1 linuxeye]# file -b linuxeye.com    <== 不显示文件名称
ASCII text
[root@server1 linuxeye]# file -i linuxeye.com     <== 显示MIME类别
linuxeye.com: text/plain; charset=us-ascii
[root@server1 linuxeye]# file -b -i linuxeye.com
text/plain; charset=us-ascii

示例二:显示符号链接的文件类型
[root@server1 linuxeye]# ll /boot/grub/menu.lst
lrwxrwxrwx 1 root root 11 Nov  9  2011 /boot/grub/menu.lst -> ./grub.conf
[root@server1 linuxeye]# file /boot/grub/menu.lst
/boot/grub/menu.lst: symbolic link to `./grub.conf'
[root@server1 linuxeye]# file -L /boot/grub/menu.lst
/boot/grub/menu.lst: ASCII text

示例三:
[root@server1 test]# file *
filestat.sh:          Bourne-Again shell script text executable
linuxeye:             directory
other:                ASCII text
remove_duplicates.sh: Bourne-Again shell script text executable
test:                 ASCII text
test_copy1:           ASCII text
test_copy2:           ASCII text
449110BA327B23C6.vox: 8086 relocatable (Microsoft)
注:使用file命令显示出来的文件类型有些情况下不一定太准确,如上面黑体显示的.vox文件格式,应该是Dialogic VOX File格式的。

转载请保留固定链接: https://linuxeye.com/command/file.html

------分隔线----------------------------
标签:file命令参数
栏目列表
推荐内容