输出 `ls -l` 命令中有多少可能的文件类型?

whn*_*nlp 3 ls file-types

通常,输出ls -l命令中可能的文件类型是d-,分别代表目录和常规文件。

除了上面,我l在 macOS 的输出中看到了另一种类型。

drwxr-xr-x   8 yongjia  staff    256 Aug 31 06:58 .
drwxr-xr-x   4 yongjia  staff    128 Aug 30 11:31 ..
lrwxr-xr-x   1 root     wheel      1 Aug 17 07:25 Macintosh HD -> /
Run Code Online (Sandbox Code Playgroud)

那么,输出中有多少可能的文件类型 ls -l命令中?

Kus*_*nda 9

报告的文件类型ls取决于底层文件系统的功能、操作系统以及ls.

l类型是常见的符号链接的文件类型。

这(应该)记录在您的ls手册中。

在 OpenBSD 上(macOS 和 AIX 具有相同的列表,但顺序不同):

-     regular file
b     block special file
c     character special file
d     directory
l     symbolic link
p     FIFO
s     socket link
Run Code Online (Sandbox Code Playgroud)

在 NetBSD 上(FreeBSD 没有aA):

-     Regular file.
a     Archive state 1.
A     Archive state 2.
b     Block special file.
c     Character special file.
d     Directory.
l     Symbolic link.
p     FIFO.
s     Socket link.
w     Whiteout.
Run Code Online (Sandbox Code Playgroud)

来自info ls(即 GNUls手册):

‘-’
     regular file
‘b’
     block special file
‘c’
     character special file
‘C’
     high performance (“contiguous data”) file
‘d’
     directory
‘D’
     door (Solaris 2.5 and up)
‘l’
     symbolic link
‘M’
     off-line (“migrated”) file (Cray DMF)
‘n’
     network special file (HP-UX)
‘p’
     FIFO (named pipe)
‘P’
     port (Solaris 10 and up)
‘s’
     socket
‘?’
     some other file type
Run Code Online (Sandbox Code Playgroud)

在 Solaris 11 上:

d
The entry is a directory.

D
The entry is a door.

l
The entry is a symbolic link.

b
The entry is a block special file.

c
The entry is a character special file.

p
The entry is a FIFO (or “named pipe”) special file.

P
The entry is an event port.

s
The entry is an AF_UNIX address family socket.

-
The entry is an ordinary file.
Run Code Online (Sandbox Code Playgroud)