3.10 读取命令的描述
whatis
本章前面介绍过man
命令的-f
选项,它可以将在man page中找到的命令描述打印到屏幕上。如果你还记得man –f
能够提供这些信息,你真的很棒!不过,要记住whatis
命令则要容易得多,它也能做同样的事:显示命令的man page的描述。
$ man -f ls
ls (1) - list directory contents
$ whatis ls
ls (1) - list directory contents
whatis
命令还支持正则表达式和通配符。要用通配符搜索man数据库,可以使用-w
选项(或--wildcard
)。
$ whatis -w ls*
ls (1) - list directory contents
lsb (8) - Linux Standard Base support for Debian
lshal (1) - List devices and their properties
lshw (1) - list hardware
lskat (6) - Lieutnant Skat card game for KDE
[Listing condensed due to length]
与不使用选项的whatis
命令相比,使用通配符可能会让搜索速度稍微慢一些,但是对于今天运行速度越来越快的计算机来说,这种影响是微不足道的,所以大可不必为此担忧。
正则表达式可以和-r
(或--regex
)选项一起使用。
$ whatis -r ^rm.*
rm (1) - remove files or directories
rmail (8) - handle remote mail received via uucp
rmdir (1) - remove empty directories
rmt (8) - remote magtape protocol module
提示 本书没有详细介绍正则表达式,但是可以阅读由Ben Forta撰写的Sams Teach Yourself Regular Expressions in 10 Minutes(ISBN: 0672325667)来获取更多信息。
虽然使用正则表达式可能会让whatis
命令的响应速度变慢,但是你可能根本不会注意到这个问题。
whatis
命令便于记忆(至少要比man –f
更容易),而且它还能快速返回一些重要信息,因此一定要记住它。