Сколько возможных типов файлов в выводе команды `ls -l`?

Стандартное awkрешение:

awk 'NF==4 && NR>1 {printf "\n" ; } 
     NF==4 { printf "%-10s %s",$1,$3} 
     NF==2 { printf ",%s",$1} 
     END   { printf "\n" ; } '

где

  • NFномер поля (номер столбца ),
  • NRномер записи (номер строки ),
  • различные условия выбирают, что печатать,
  • printfне печатает завершающую новую строку.
2
31.08.2019, 13:39
2 ответа

Типы файлов, указанные в 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

В NetBSD (FreeBSD имеет то же самое без aиA):

-     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.

Из info ls(, то есть из руководства GNU ls):

‘-’
     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

На Солярисе 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.
9
27.01.2020, 21:51

Вы можете найти эту информацию на страницах info, выполнив info coreutils 'ls invocation'. В моей системе он включает следующий отрывок:

 The file type is one of the following characters:

`-'
      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
1
27.01.2020, 21:51

Теги

Похожие вопросы