最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux系統(tǒng)中file命令的使用詳解

cnblogs   發(fā)布時(shí)間:2015-10-14 12:10:36   作者:瀟湘隱者   我要評(píng)論
這篇文章主要介紹了Linux系統(tǒng)中file命令的使用詳解,是Linux入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下

命令簡(jiǎn)介:

該命令用來(lái)識(shí)別文件類型,也可用來(lái)辨別一些文件的編碼格式。它是通過(guò)查看文件的頭部信息來(lái)獲取文件類型,而不是像Windows通過(guò)擴(kuò)展名來(lái)確定文件類型的。

執(zhí)行權(quán)限 :All User

指令所在路徑:/usr/bin/file

 
命令語(yǔ)法:

復(fù)制代碼
代碼如下:

file [ -bchikLnNprsvz ] [ -f namefile ] [ -F separator ] [ -m magicfiles ] file ...

命令參數(shù):

下表列出了部分常用的參數(shù)。

使用示例:
1:查看file命令的幫助信息


復(fù)制代碼
代碼如下:
[root@DB-Server ~]# file --help

Usage: file [OPTION]... [FILE]...
Determine file type of FILEs.  

-m, --magic-file LIST      use LIST as a colon-separated list of magic                               number files 
-z, --uncompress           try to look inside compressed files 
-b, --brief                do not prepend filenames to output lines 
-c, --checking-printout    print the parsed form of the magic file, use in                               conjunction with -m to debug a new magic file                               before  installing it 
-f, --files-from FILE      read the filenames to be examined from FILE 
-F, --separator string     use string as separator instead of `:' 
-i, --mime                 output mime type strings 
-k, --keep-going           don't stop at the first match 
-L, --dereference          causes symlinks to be followed  -n, --no-buffer            do not buffer output 
-N, --no-pad               do not pad output 
-p, --preserve-date        preserve access times on files 
-r, --raw                  don't translate unprintable chars to \ooo 
-s, --special-files        treat special (block/char devices) files as                             ordinary ones     
 --help                 display this help and exit     
 --version              output version information and exit
當(dāng)然你也可以使用 man file 獲取更加詳細(xì)的幫助文檔信息。

2:不輸出文件名稱,只顯示文件格式以及編碼
通過(guò)下面兩個(gè)命令對(duì)時(shí),就可以清晰的了解參數(shù)-b的作用。
 

復(fù)制代碼
代碼如下:

[root@DB-Server ~]# file Temp.txt Temp.txt: UTF-8 Unicode text, with very long lines, with CRLF line terminators[root@DB-Server ~]# file -b Temp.txtUTF-8 Unicode text, with very long lines, with CRLF line terminators


3: 輸出mime類型的字符串
 

復(fù)制代碼
代碼如下:

[root@DB-Server ~]# file -i Temp.txt Temp.txt: text/plain; charset=utf-8

 

4: 查看文件中的文件名的文件類型

這個(gè)參數(shù)非常適合shell腳本去查找、判別某種文件類型的數(shù)據(jù)。
 

你可以像下面這樣使用 file 命令確定文件的類型。下面的截圖顯示了用 file 命令確定不同文件類型的例子。

復(fù)制代碼
代碼如下:

tecmint@tecmint ~/Linux-Tricks $ dir
BACKUP master.zip
crossroads-stable.tar.gz num.txt
EDWARD-MAYA-2011-2012-NEW-REMIX.mp3 reggea.xspf
Linux-Security-Optimization-Book.gif tmp-link
tecmint@tecmint ~/Linux-Tricks $ file BACKUP/
BACKUP/: directory
tecmint@tecmint ~/Linux-Tricks $ file master.zip
master.zip: Zip archive data, at least v1.0 to extract
tecmint@tecmint ~/Linux-Tricks $ file crossroads-stable.tar.gz
crossroads-stable.tar.gz: gzip compressed data, from Unix, last modified: Tue Apr 5 15:15:20 2011
tecmint@tecmint ~/Linux-Tricks $ file Linux-Security-Optimization-Book.gif
Linux-Security-Optimization-Book.gif: GIF image data, version 89a, 200 x 259
tecmint@tecmint ~/Linux-Tricks $ file EDWARD-MAYA-2011-2012-NEW-REMIX.mp3
EDWARD-MAYA-2011-2012-NEW-REMIX.mp3: Audio file with ID3 version 2.3.0, contains: MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, JntStereo
tecmint@tecmint ~/Linux-Tricks $ file /dev/sda1
/dev/sda1: block special
tecmint@tecmint ~/Linux-Tricks $ file /dev/tty1
/dev/tty1: character special

5:嘗試去解讀壓縮文件的內(nèi)容
 

復(fù)制代碼
代碼如下:

[root@DB-Server ~]# file -z Temp.txt.gz Temp.txt.gz: UTF-8 Unicode text, with very long lines, with CRLF line terminators (gzip compressed data, was "Temp.txt", from Unix, last modified: Tue Jun 24 00:34:15 2014)[root@DB-Server ~]#

 

6: 查看軟鏈接對(duì)應(yīng)文件的文件類型

如下所示,創(chuàng)建一個(gè)軟鏈接sfile,然后分別用file 和帶參數(shù)的file -L查看

復(fù)制代碼
代碼如下:

[root@DB-Server ~]# ln -s Temp.txt.gz sfile[root@DB-Server ~]# file sfile sfile: symbolic link to `Temp.txt.gz'[root@DB-Server ~]# file -L sfile sfile: gzip compressed data, was "Temp.txt", from Unix, last modified: Tue Jun 24 00:34:15 2014[root@DB-Server ~]#

相關(guān)文章

最新評(píng)論

南雄市| 紫云| 廊坊市| 保山市| 酉阳| 永济市| 称多县| 申扎县| 敦煌市| 辰溪县| 宜章县| 霞浦县| 玛曲县| 余姚市| 扶风县| 凤城市| 宣威市| 大城县| 呼图壁县| 虹口区| 贵溪市| 贡嘎县| 海安县| 蓝山县| 舒兰市| 界首市| 万山特区| 公主岭市| 湖南省| 桐柏县| 鄢陵县| 嘉祥县| 分宜县| 北票市| 城步| 黄浦区| 万盛区| 常宁市| 额济纳旗| 襄汾县| 五莲县|