日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > linux >内容正文

linux

linux命令详解:file命令

發(fā)布時(shí)間:2023/12/19 linux 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux命令详解:file命令 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

前言

file命令可以獲取多種文件類型,包括文本文件、腳本文件、源碼文件、多媒體文件(音頻視頻)等。file是通過(guò)查看文件的頭部?jī)?nèi)容,來(lái)獲取文件的類型,而不像Window那樣是通過(guò)擴(kuò)展名來(lái)確定文件類型的。

命令用法

-z 獲取壓縮文件的類型(不能是用tar打包過(guò)的),比如gzip、zip等壓縮過(guò)的

-L 獲取軟鏈所指向的文件的類型

-f 指定文件列表參數(shù),獲取該列表里面的所有文件的類型

常見(jiàn)用法

file FileName

1: [root@master lianxi]# file test 2: test: ASCII text 1: [root@master lianxi]# > 1 2: [root@master lianxi]# file 1 3: 1: empty

file使用通配符,獲取多個(gè)文件的類型

file *.lua (以.lua結(jié)尾的文件)

1: [root@master lianxi]# file *.lua 2: 2.lua: ASCII text 3: 3.lua: ASCII text 4: 4.lua: ASCII text

數(shù)據(jù)文件類型(某些程序?qū)S玫臄?shù)據(jù)格式)

1: [root@master lianxi]# file /var/log/lastlog 2: /var/log/lastlog: data

Python腳本文件

1: [root@master lianxi]# file print.py 2: print.py: a /bin/python script text executable

-z 參數(shù),可以獲取用gzip、zip壓縮過(guò)的文件的類型

1: [root@master lianxi]# gzip print.py 2: [root@master lianxi]# ls print.py.gz 3: print.py.gz 4: [root@master lianxi]# zip -r print.py.zip print.py.gz 5: adding: print.py.gz (stored 0%) 6: [root@master lianxi]# ls print.py.zip 7: print.py.zip 8: [root@master lianxi]# file print.py.* 9: print.py.gz: gzip compressed data, was "print.py", from Unix, last modified: Fri Jun 14 20:48:14 2013 10: print.py.zip: Zip archive data, at least v1.0 to extract

-L 獲取軟鏈指向的文件的類型。默認(rèn)是返回軟鏈本身類型

1: [root@master lianxi]# ln -s test test.soft 2: [root@master lianxi]# ls -l test* 3: -rw-r--r-- 1 root root 25 Jun 14 20:09 test 4: lrwxrwxrwx 1 root root 4 Jun 14 20:51 test.soft -> test 5: [root@master lianxi]# file test.soft 6: test.soft: symbolic link to `test' 7: [root@master lianxi]# file -L test.soft 8: test.soft: ASCII text 9: [root@master lianxi]#

-f 獲取一個(gè)文件名列表的所有文件的類型。1)注意路徑是否正確 2)每行一個(gè)文件名

1: [root@master dir]# ls 2: 1 2 3 3: [root@master dir]# ls > a 4: [root@master dir]# cat a 5: 1 6: 2 7: 3 8: a 9: [root@master dir]# file -f a 10: 1: ASCII text 11: 2: ASCII text 12: 3: empty 13: a: ASCII text

特殊說(shuō)明

1)在Window中,Windows系統(tǒng)對(duì)文件系統(tǒng)文件的標(biāo)識(shí)是通過(guò)其擴(kuò)展名。但是Windows上的程序自己也可以通過(guò)文件內(nèi)容來(lái)判斷文件內(nèi)容類型

2)file 是通過(guò)讀取文件頭部?jī)?nèi)容,來(lái)獲取文件類型,比如BASH腳本文件以#!/bin/bash 或Python腳本以#!/bin/python等,file讀取其頭部信息判斷類型。

3)file可以辨識(shí)的文件類型很多,文本文件、腳本文件、數(shù)據(jù)文件、多媒體文件等。

總結(jié)

file命令,獲取文件類型。

轉(zhuǎn)載于:https://www.cnblogs.com/xujie2013/p/3408516.html

總結(jié)

以上是生活随笔為你收集整理的linux命令详解:file命令的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。