zoukankan      html  css  js  c++  java
  • file命令详解

    Linux file命令

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

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

    用法:

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

    参数:

    -b  列出辨识结果时,不显示文件名称。

    -C   写一个magic.mgc输出文件,其中包含预先解析的magic文件或目录版本

    -c  详细显示指令执行过程,便于排错或分析程序执行的情形。

    -f<名称文件>  指定名称文件,其内容有一个或多个文件名称时,让file依序辨识这些文件,格式为每列一个文件名称。

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

    -m <魔法数字文件>  指定魔法数字文件。

    -v  显示版本信息。

    -z  尝试去解读压缩文件的内容。

    [文件或目录...] 要确定类型的文件列表,多个文件之间使用空格分开,可以使用shell通配符匹配多个文件

    实例:

    1、显示文件类型:

    [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

    2、显示符号链接的文件类型:

    [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
  • 相关阅读:
    mysql 格林威治时间
    设置Highcharts刻度间距
    在PHP中判断单个字符是不是中文字符
    将ip以整形数据存储在数据库中的相关操作
    【Demo 0016】Windows 基本数据结构
    【Demo 0019】编码转换
    【Demo 0018】文字编码
    【Demo 0014】图形对象路径
    【Demo 0010】绘图对象区域
    【Demo 0017】Win32 基本结构体(1)
  • 原文地址:https://www.cnblogs.com/jkin/p/10199952.html
Copyright © 2011-2022 走看看