以前一直沒注意到 apropos 這個好用的工具。只要輸入 apropos [關鍵字],就能列出與該關鍵字功能相關的指令。它實際做的是搜尋其他指令的描述資訊,把相關指令彙整出來——不一定第一個就是你要的,但往往能幫你回想起真正需要的那個指令。
使用方法很簡單,細節可參考 man apropos。以下用 apropos 查找與 sort 相關的指令:
apropos sortalphasort [scandir] (3) - scan a directory for matching entriesbsearch (3) - binary search of a sorted arraybunzip2 (1) - a block-sorting file compressorbzip2 (1) - a block-sorting file compressorcomm (1) - compare two sorted files line by lineqsort (3) - sorts an arraysort (1) - sort lines of text filestsort (1) - perform topological sortuniq (1) - remove duplicate lines from a sorted file
從這份清單裡,除了核心的 sort,你還能意外發現 comm、uniq、tsort 等實用工具,這正是 apropos 的迷人之處。