Linux— file命令 用于辨识文件类型

时间:2020-06-16 15:05:48   收藏:0   阅读:76

Linux file命令用于辨识文件类型。

通过file指令,我们得以辨识该文件的类型。

语法

file [-bcLvz][-f <名称文件>][-m <魔法数字文件>...][文件或目录...]

参数

实例

显示文件类型:

[root@localhost ~]# file install.log
install.log: UTF-8 Unicode text

[root@localhost ~]# file -b install.log      <== 不显示文件名称
UTF-8 Unicode text

[root@localhost ~]# file -i install.log      <== 显示MIME类别。
install.log: text/plain; charset=utf-8

[root@localhost ~]# file -b -i install.log
text/plain; charset=utf-8

显示符号链接的文件类型

[root@localhost ~]# ls -l /var/mail
lrwxrwxrwx 1 root root 10 08-13 00:11 /var/mail -> spool/mail

[root@localhost ~]# file /var/mail
/var/mail: symbolic link to `spool/mail‘

[root@localhost ~]# file -L /var/mail
/var/mail: directory

[root@localhost ~]# file /var/spool/mail
/var/spool/mail: directory

[root@localhost ~]# file -L /var/spool/mail
/var/spool/mail: directory



参考:https://www.runoob.com/linux/linux-comm-file.html
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!