Saturday, January 19, 2013

apropos and whatis for Cygwin

apropos and whatis are Unix-y commands that display a short description of other commands available on your system.

apropos is handy when you're looking for a particular function, say reading the contents of compressed files. It tends to be over-zealous with keywords, so for example, typing apropos compare compressed files returns 184 one line descriptions on my system. Typing just apropos compressed returns a more manageable 22 descriptions:

$ apropos compressed
bzcmp []             (1)  - compare bzip2 compressed files
bzdiff []            (1)  - compare bzip2 compressed files
...
zmore []             (1)  - file perusal filter for crt viewing of compressed text

whatis comes in when you know the name of an unfamiliar command, but you want a simple description of it's purpose:

$ whatis zmore
zmore []             (1)  - file perusal filter for crt viewing of compressed text

To use apropos (or man -k or whatis) in Cygwin, you must first create the whatis database by running the /usr/sbin/makewhatis command, probably with admin permissions to write the database.

Note (15 Jan 2014): apropos and whatis will not work from a Windows command prompt unless you've put the Cygwin bin directory ahead of the Windows and Windows\System32 directories in the PATH. Otherwise, apropos and whatis, which are shell scripts, will try to use the Windows 'find'command instead of the Cygwin 'find' command