file of Linux command

file [options] [filename]

Confirm file type

(1). Common options

magic file refers to which files have a special file format

-b, --brief do not list file names
-c,--checking-printout Check the specified magic file (by default, /etc/magic file) for formatting errors. This verification is generally not performed. File input is not performed under this flag.
-f <name file> Specifies the name file, when its content has one or more file names, let file identify these files in sequence, the format is one file name per column
-L,--dereferencd directly display the file type of the file pointed to by the symbolic link
-m,--magic-file LIST specify the filename of the magic file
-v,--version display version information
-z,uncompress try to view compressed file contents

(2). Examples

show file type

[root@CentOS6 desktop]# cd ~
[root@CentOS6 ~]# file install.log
install.log: UTF-8 Unicode text
[root@CentOS6 ~]# file -b install.log
UTF-8 Unicode text
[root@CentOS6 ~]# file -i install.log
install.log: text/plain; charset=utf-8
[root@CentOS6 ~]# file -bi install.log
text/plain; charset=utf-8

 Show file types of symbolic links

[root@CentOS6 ~]# ls -l /var/mail
lrwxrwxrwx. 1 root root 10 3月  13 18:14 /var/mail -> spool/mail
[root@CentOS6 ~]# file /var/mail
/var/mail: symbolic link to `spool/mail'
[root@CentOS6 ~]# file -L /var/mail
/ var / mail: directory
[root@CentOS6 ~]# file /var/spool/mail
/var/spool/mail: directory
[root@CentOS6 ~]# file -L /var/spool/mail
/var/spool/mail: directory

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325207615&siteId=291194637