【Linux命令每日一知】file--输出文件类型

2020-07-14 上海

file

用来显示文件的类型

man page: file — determine file type

参数选项

参数 说明
-b 简化输出,不输出文件名
-i 输出文件对应类型mime
-L 如果文件是链接文件,显示最终文件的信息
-f name_file 处理name_file文件中所包含的文件名信息,逐行逐行读取
-z 如果文件是压缩文件,则显示被压缩文件的类型,而不是仅仅显示压缩文件类型

示例

[root@localhost grub2]# file /bin/bash
/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=85e3da5a087950e7aaeb7893c056218a8874d2e5, stripped
[root@localhost grub2]# file /home/jiangjian/kernel/linux-3.10.61.tar.gz 
/home/jiangjian/kernel/linux-3.10.61.tar.gz: gzip compressed data, from Unix, last modified: Sat Nov 22 02:51:35 2014, max compression
[root@localhost grub2]# file -z /home/jiangjian/kernel/linux-3.10.61.tar.gz 
/home/jiangjian/kernel/linux-3.10.61.tar.gz: POSIX tar archive (gzip compressed data, from Unix, last modified: Sat Nov 22 02:51:35 2014, max compression)    
[root@localhost grub2]# file /home/jiangjian/1.html 
/home/jiangjian/1.html: ASCII text
[root@localhost grub2]# file -i /home/jiangjian/1.html 
/home/jiangjian/1.html: text/plain; charset=us-ascii
[root@localhost grub2]# 


你可能感兴趣的:(Linux命令每日一知)