file:显示文件的类型

xiaohai 2021-05-05 16:56:57 1951人围观 标签: Linux 
简介 file命令是显示文件的类型
说明

  file命令是显示文件的类型

格式

  file [option] [file]

常用参数说明

-b:使用精简的格式输出,不输出文件名

示例

[root@localhost test]# ll
总用量 8
-rw-r--r--. 1 root  root   0 5月   3 16:57 a b
lrwxrwxrwx. 1 root  root   9 5月   3 07:30 abc1.txt -> test5.txt
lrwxrwxrwx. 1 root  root  17 5月   3 08:46 abc2.txt -> ../test/test2.txt
drwxr-xr-x. 4 root  root  42 5月   3 16:52 dir01
drwxr-xr-x. 2 root  root   6 5月   3 07:00 dir02
drwxr-xr-x. 2 root  root   6 5月   3 07:00 dir03
drwxr-xr-x. 2 root  root   6 5月   3 07:00 dir04
drwxr-xr-x. 2 root  root   6 5月   3 07:00 dir05
-rw-r--r--. 1 nginx nginx 27 5月   3 15:31 test2.txt
-rw-r--r--. 1   555 root   0 5月   3 07:00 test3.txt
-rw-r--r--. 1 root  root   2 5月   3 08:42 test5.txt

#未使用参数部分
[root@localhost test]# file test2.txt 
test2.txt: ASCII text
[root@localhost test]# file dir01/
dir01/: directory
[root@localhost test]# file abc1.txt 
abc1.txt: symbolic link to test5.txt

#使用参数部分
[root@localhost test]# file -b test2.txt 
ASCII text
[root@localhost test]# file -b dir01
directory
[root@localhost test]# file -b abc1.txt 
symbolic link to test5.txt