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

      

    基础命令学习目录首页

    原文链接:https://blog.csdn.net/yujin2010good/article/details/78786051

    file命令用来识别文件类型,也可用来辨别一些文件的编码格式。它是通过查看文件的头部信息来获取文件类型,而不是像Windows通过扩展名来确定文件类型的。

    1.命令格式:
    file [ -bchikLnNprsvz ] [ -f namefile ] [ -F separator ] [ -m magicfiles ] file ...

    2.命令功能:
    用于查看日历等时间信息,如只有一个参数,则表示年份(1-9999),如有两个参数,则表示月份和年份
    文本
    [root@sande-lvs01 ~]# file /etc/resolv.conf
    /etc/resolv.conf: ASCII text
    目录
    [root@sande-lvs01 ~]# file /usr/bin
    /usr/bin: directory
    二进制文件
    [root@sande-lvs01 ~]# file /usr/bin/ssh-keygen 
    /usr/bin/ssh-keygen: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, 
    可执行脚本
    [root@sande-lvs01 ~]# file zabbix_agent.sh 
    zabbix_agent.sh: Bourne-Again shell script text executable
    字符设备
    [root@sande-lvs01 ~]# file /dev/tty1
    /dev/tty1: character special
    块设备文件
    [root@sande-lvs01 ~]# file /dev/sda
    /dev/sda: block special
    连接文件
    [root@sande-lvs01 ~]# file /bin/sh
    /bin/sh: symbolic link to `bash'

    3.命令参数:
    -b        列出文件辨识结果时,不显示文件名称。
    -c        详细显示指令执行过程,便于排错或分析程序执行的情形
    -f        列出文件中文件名的文件类型
    -F        使用指定分隔符号替换输出文件名后的默认的":"分隔符。
    -i        输出mime类型的字符串
    -L        查看对应软链接对应文件的文件类型
    -z        尝试去解读压缩文件的内容
    --help    显示命令在线帮助
    -version    显示命令版本信息

    -b是不显示文件名
    [root@sande-lvs01 ~]# file -b install.log
    ASCII text
    -i输出mime类型的字符串
    [root@sande-lvs01 ~]# file -i install.log
    install.log: text/plain; charset=us-ascii
    -F使用指定分隔符号替换输出文件名后的默认的":"分隔符。
    [root@sande-lvs01 ~]# file -F "--" install.log
    install.log-- ASCII text
    [root@sande-lvs01 ~]# file -F "++" install.log
    install.log++ ASCII text
    [root@sande-lvs01 ~]# file -F "==" install.log
    install.log== ASCII text3
    [root@sande-lvs01 ~]# file -z install.log.tar.zip 
    install.log.tar.zip: POSIX tar archive (GNU) (gzip compressed data, from Unix, last modified: Tue Dec 12 20:55:23 2017)

  • 相关阅读:
    showSoftInput不起作用
    GridView在PopWindow中OnItemClick不响应
    白盒测试范围
    Winform的ListBox的ValueMember和DisplayMember绑定的名称所属对象必须是Public的。
    谷歌浏览器安装adblock广告屏蔽插件
    php+curl上传文件
    win10我能ping通他人,但他人ping不同我
    自己的配置文件以及操作
    安装redis,执行make test时遇到You need tcl 8.5 or newer in order to run the Redis test
    安装redis时遇到zmalloc.h:50:31: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录
  • 原文地址:https://www.cnblogs.com/machangwei-8/p/9570345.html
Copyright © 2011-2022 走看看