当前位置: 技术问答>linux和unix
linux 是怎么判断文件类型的?在线等待
来源: 互联网 发布时间:2015-02-03
本文导语: linux 是怎么判断文件类型的?比如说linux怎么直到一个文件是二进制的可执行文件,另一个是文本的脚本文件.好像不是根据文件的后缀呀? | # man file . . . File tests eac...
linux 是怎么判断文件类型的?比如说linux怎么直到一个文件是二进制的可执行文件,另一个是文本的脚本文件.好像不是根据文件的后缀呀?
|
# man file
. . .
File tests each argument in an attempt to classify it.
There are three sets of tests, performed in this order:
filesystem tests, magic number tests, and language tests.
The first test that succeeds causes the file type to be
printed.
The type printed will usually contain one of the words
text (the file contains only printing characters and a few
common control characters and is probably safe to read on
an ASCII terminal), executable (the file contains the
result of compiling a program in a form understandable to
some UNIX kernel or another), or data meaning anything
else (data is usually `binary' or non-printable).
...
. . .
File tests each argument in an attempt to classify it.
There are three sets of tests, performed in this order:
filesystem tests, magic number tests, and language tests.
The first test that succeeds causes the file type to be
printed.
The type printed will usually contain one of the words
text (the file contains only printing characters and a few
common control characters and is probably safe to read on
an ASCII terminal), executable (the file contains the
result of compiling a program in a form understandable to
some UNIX kernel or another), or data meaning anything
else (data is usually `binary' or non-printable).
...