Linux命令學習總結 flie命令

2021-10-22 14:31:10 字數 2619 閱讀 2557

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, --mimeoutput mime type strings

-k, --keep-goingdon't stop at the first match

-l, --dereferencecauses symlinks to be followed

-n, --no-bufferdo not buffer output

-n, --no-paddo not pad output

-p, --preserve-date preserve access times on files

-r, --rawdon't translate unprintable chars to \ooo

-s, --special-files treat special (block/char devices) files as

ordinary ones

--helpdisplay this help and exit

--versionoutput version information and exit

當然你也可以使用 man file 獲取更加詳細的幫助文件資訊。

2:檢視檔案型別

例如,如下所示,temp.txt 檔案型別為text,編碼為utf-8 unicode

[root@db-server ~]# file temp.txt

temp.txt: utf-8 unicode text, with very long lines, with crlf line terminators

3:不輸出檔名稱,只顯示檔案格式以及編碼

通過下面兩個命令對時,就可以清晰的了解引數-b的作用。

[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.txt

utf-8 unicode text, with very long lines, with crlf line terminators

4: 輸出mime型別的字串

[root@db-server ~]# file -i temp.txt

temp.txt: text/plain; charset=utf-8

5: 檢視檔案中的檔名的檔案型別

這個引數非常適合shell指令碼去查詢、判別某種檔案型別的資料。

[root@db-server ~]# cat >test

/root/install.log

it is only one test file

[2]+ stoppedcat > test

[root@db-server ~]# file -f test

/root/install.log: ascii text

it is only one test file: error: cannot open `it is only one test file' (no such file or directory)

[root@db-server ~]#

[root@db-server ~]#

5: 使用指定分隔符號替換輸出檔名後的預設的「:」分隔符。

感覺這個引數很雞肋!我搞明白這個引數的作用時,很是納悶。

6:嘗試去解讀壓縮檔案的內容

[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 ~]#

7: 檢視軟鏈結對應檔案的檔案型別

如下所示,建立乙個軟鏈結sfile,然後分別用file 和帶引數的file -l檢視

[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 ~]#

linux命令學習之網路命令和監控命令

面列出來的10個基礎的每個linux使用者都應該知道的網路和監控命令,大家參考使用吧 網路和監控命令類似於這些 hostname,ping,ifconfig,iwconfig,netstat,nslookup,traceroute,finger,telnet,ethtool 用於檢視linux伺服器...

linux命令基本總結

題目 對課堂所講的檔案目錄類,系統資訊類,程序管理類等基本命令程序演練,同時觀察其結果。最後寫一篇關於基本命令的總結 包括命令的基本作用,命令執行後的結果,演練過程 現的問題等 1.linux命令的特點 在linux系統中命令區分大小寫 tab鍵來自動補齊命令 上下翻閱鍵 多行命令分隔 轉換成後台 ...

Linux命令大全

linux指令速成 在書店和網路中會有許多關於linux操作指令的書籍和頁面,許多介紹的都很全面,我們要想系統的掌握這方面的知識,這些資料是很不錯的選擇。但是作為乙個初學著,或者想要在較短的時間內就能簡單的應用linux,這樣做似乎會比較慢,其實我們大可不必儲備很多操作知識才去進行應用,就像我們學習...