LINUX

LINUX FILE指令

介紹

file指令用來顯示檔案的格式。

語法

file [options] files

常用的options

-b            Omit filenames (left column of output).

-i            Print MIME types for the file, such as "text/plain" or "audio/mpeg", instead of the usual output.

-f name_file  Read filenames, one per line, from the given name_file, and report their types. Afterward, process filenames on the command line as usual.

-L            Follow symbolic links, reporting the type of the destination file instead of the link.

-z            If a file is compressed, examine the uncompressed content to decide the file type, instead of reporting "compressed data."

範例

你可以顯示檔案的格式:

⤍ file letter.txt
letter.txt: ASCII text

⤍ file key.pem
key.pem: PEM RSA private key

⤍ file /usr/bin/who
/usr/bin/who: ELF 64-bit LSB pie executable, ...

⤍ file letter.txt key.pem
letter.txt: ASCII text
key.pem:    PEM RSA private key

使用-b可以隱藏檔名:

⤍ file -b letter.txt
ASCII text

⤍ file -b letter.txt key.pem
ASCII text
PEM RSA private key

發佈留言