如何获取文件夹中每个可执行文件的简要说明?

时间:2018-05-13 19:51:31

标签: linux bash unix terminal command-line-interface

我的Unix系统在usr / bin文件夹下有很多可执行文件。我想得到每个可执行文件的简要说明,类似于“命名”部分下man命令显示的简要说明。最终输出将是这样的列表(按字母顺序排列):

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 :(得分:3)

使用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