Linux之file命令

用来探测给定文件的类型,file命令 用来探测给定文件的类型。file命令对文件的检查分为文件系统、魔法幻数检查和语言检查3个过程。

命令语法

file [选项][参数]

命令选项

命令参数

文件:要确定类型的文件列表,多个文件之间使用空格分开,可以使用shell通配符匹配多个文件。

显示文件类型

> file outfile.txt 
outfile.txt: ASCII text

> file -b outfile.txt  <== 不显示文件名称
ASCII text

> file -i outfile.txt  <== 显示MIME类别。
outfile.txt: text/plain; charset=us-ascii

> file -i -b outfile.txt 
text/plain; charset=us-ascii

一些常见的类型包括:

显示符号链接的文件类型

> file system-release
system-release: symbolic link to `centos-release'

> file -L /tmp/
/tmp/: sticky directory

解读压缩文件的内容

> file -z Python-3.6.4.tgz 
Python-3.6.4.tgz: POSIX tar archive (GNU) (gzip compressed data, from Unix, last modified: Tue Dec 19 13:36:13 2017, max compression) 

解读可执行程序

> file /usr/bin/ls
/usr/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=aaf05615b6c91d3cbb076af81aeff531c5d7dfd9, stripped

> file -i /usr/bin/ls   <== 显示MIME类别
/usr/bin/ls: application/x-executable; charset=binary
展开阅读全文

页面更新:2024-05-04

标签:命令   通配符   文件类型   文件名称   符号   选项   文本   类别   参数   过程   类型   文档   文件   程序   内容   科技

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top