• 要找福利?记不住网址?搜不到?如何与我们保持联系?试试 CTRL+D 把零点博客添加进您的浏览器收藏夹,一键直达永不失联!

Linux file命令

linux系统 涛涛 163次浏览 0个评论

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

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

语法

<span class="pln">file </span><span class="pun">[-</span><span class="pln">bcLvz</span><span class="pun">][-</span><span class="pln">f </span><span class="pun"><名称文件>][-</span><span class="pln">m </span><span class="pun"><魔法数字文件>...][文件或目录...]</span>

参数

  • -b  列出辨识结果时,不显示文件名称。
  • -c  详细显示指令执行过程,便于排错或分析程序执行的情形。
  • -f<名称文件>  指定名称文件,其内容有一个或多个文件名称时,让file依序辨识这些文件,格式为每列一个文件名称。
  • -L  直接显示符号连接所指向的文件的类别。
  • -m<魔法数字文件>  指定魔法数字文件。
  • -v  显示版本信息。
  • -z  尝试去解读压缩文件的内容。
  • [文件或目录…] 要确定类型的文件列表,多个文件之间使用空格分开,可以使用shell通配符匹配多个文件。

实例

显示文件类型:

<span class="pun">[</span><span class="pln">root@localhost </span><span class="pun">~]#</span><span class="pln"> file install</span><span class="pun">.</span><span class="pln">log
install</span><span class="pun">.</span><span class="pln">log</span><span class="pun">:</span><span class="pln"> UTF</span><span class="pun">-</span><span class="lit">8</span> <span class="typ">Unicode</span><span class="pln"> text

</span><span class="pun">[</span><span class="pln">root@localhost </span><span class="pun">~]#</span><span class="pln"> file </span><span class="pun">-</span><span class="pln">b install</span><span class="pun">.</span><span class="pln">log      </span><span class="pun"><==</span> <span class="pun">不显示文件名称</span><span class="pln">
UTF</span><span class="pun">-</span><span class="lit">8</span> <span class="typ">Unicode</span><span class="pln"> text

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

<span class="pun">[</span><span class="pln">root@localhost </span><span class="pun">~]#</span><span class="pln"> file </span><span class="pun">-</span><span class="pln">b </span><span class="pun">-</span><span class="pln">i install</span><span class="pun">.</span><span class="pln">log
text</span><span class="pun">/</span><span class="pln">plain</span><span class="pun">;</span><span class="pln"> charset</span><span class="pun">=</span><span class="pln">utf</span><span class="pun">-</span><span class="lit">8</span>

显示符号链接的文件类型

<span class="pun">[</span><span class="pln">root@localhost </span><span class="pun">~]#</span><span class="pln"> ls </span><span class="pun">-</span><span class="pln">l </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">mail
lrwxrwxrwx </span><span class="lit">1</span><span class="pln"> root root </span><span class="lit">10</span> <span class="lit">08</span><span class="pun">-</span><span class="lit">13</span> <span class="lit">00</span><span class="pun">:</span><span class="lit">11</span> <span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">mail </span><span class="pun">-></span><span class="pln"> spool</span><span class="pun">/</span><span class="pln">mail

</span><span class="pun">[</span><span class="pln">root@localhost </span><span class="pun">~]#</span><span class="pln"> file </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">mail
</span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">mail</span><span class="pun">:</span><span class="pln"> symbolic link to </span><span class="str">`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</span>

欢迎转载本文:Linux file命令
喜欢 (0)
[ld]
分享 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址