linux中的file命令
linux中的file命令
Linux中的file命令用于辨識(shí)文件的類(lèi)型,下面由學(xué)習(xí)啦小編為大家整理了linux中的file命令的相關(guān)知識(shí),希望對(duì)大家有幫助!
linux中的file命令詳解
Linux file命令用于辨識(shí)文件類(lèi)型。
通過(guò)file指令,我們得以辨識(shí)該文件的類(lèi)型。
語(yǔ)法
file [-beLvz][-f <名稱(chēng)文件>][-m <魔法數(shù)字文件>...][文件或目錄...]
參數(shù):
-b 列出辨識(shí)結(jié)果時(shí),不顯示文件名稱(chēng)。
-c 詳細(xì)顯示指令執(zhí)行過(guò)程,便于排錯(cuò)或分析程序執(zhí)行的情形。
-f<名稱(chēng)文件> 指定名稱(chēng)文件,其內(nèi)容有一個(gè)或多個(gè)文件名稱(chēng)呢感,讓file依序辨識(shí)這些文件,格式為每列一個(gè)文件名稱(chēng)。
-L 直接顯示符號(hào)連接所指向的文件的類(lèi)別。
-m<魔法數(shù)字文件> 指定魔法數(shù)字文件。
-v 顯示版本信息。
-z 嘗試去解讀壓縮文件的內(nèi)容。
[文件或目錄...] 要確定類(lèi)型的文件列表,多個(gè)文件之間使用空格分開(kāi),可以使用shell通配符匹配多個(gè)文件。
linux中的file命令實(shí)例
顯示文件類(lèi)型:
[root@localhost ~]# file install.log
install.log: UTF-8 Unicode text
[root@localhost ~]# file -b install.log <== 不顯示文件名稱(chēng)
UTF-8 Unicode text
[root@localhost ~]# file -i install.log <== 顯示MIME類(lèi)別。
install.log: text/plain; charset=utf-8
[root@localhost ~]# file -b -i install.log
text/plain; charset=utf-8
顯示符號(hào)鏈接的文件類(lèi)型
[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