Как получить краткое описание для каждого исполняемого файла в папке? - PullRequest
0 голосов
/ 13 мая 2018

Моя система Unix имеет много исполняемых файлов в папке usr / bin.Я хочу получить краткое описание каждого исполняемого файла, похожее на краткое описание, отображаемое командой man в разделе «NAME».Окончательный вывод будет выглядеть следующим образом (в алфавитном порядке):

ls - list directory contents
sort - sort or merge records (lines) of text and binary files
wc - word, line, character, and byte count

Как я могу это сделать на bash?

1 Ответ

0 голосов
/ 13 мая 2018

С GNU find, xargs и whatis:

find /usr/bin/ -executable -printf '%f\0' | xargs -0 whatis 2>/dev/null

Вывод (например):

ls (1)               - list directory contents
sort (1)             - sort lines of text files
wc (1)               - print newline, word, and byte counts for each file
find (1)             - search for files in a directory hierarchy
xargs (1)            - build and execute command lines from standard input
whatis (1)           - display one-line manual page descriptions
...