< Searching with apropos >
What if you need to do a specific task but don't know what program or command to use for the task? Every man page entry contains a short description of the program, but the problem is that you don't know what program to use and what man page to read! With the apropos
command you can search those descriptions and find the right tool for the job. You can use keywords to search both program names and their descriptions.
Let's have an example. Suppose you have a compressed gzip file, and you want to uncompress it. You probably want to use a program whose description or name contains the word "gzip", and now you can use apropos
for finding such a program:
$ apropos gzip
gzip (1) - compress or expand files
zforce (1) - force a '.gz' extension on all gzip files
$
Now when you look at the output of apropos, you probably see that gzip
might be what you're looking for. Now you know the command name, and can go read its man page:
$ man gzip
Let's have another example. As you know, you can list the directory contents with the ls
command. But there are other commands for listing the directory contents, too! Now let's try to find out what those commands might be. The first thing that comes into your mind would probably be something like this:
$ apropos directory
This command probably gives you many lines of output, because "directory" is pretty common word in the descriptions of commands, and now you have a list of commands where most of the commands have nothing to do with listing the directory contents. But with apropos
, you can use more than just one keyword:
$ apropos list directory
This didn't help much, though! Now you have even longer list than before! Why? Because apropos
displays commands whose description has either "list" or "directory". In some situations this might be good, and exactly what you want, but not right now. Let's try more:
$ apropos "list directory"
dir (1) - list directory contents
ls (1) - list directory contents
vdir (1) - list directory contents
$
This gave you the output you wanted. Because we used double quotes here, apropos
searched for a string that says "list directory", rather than for the occurrence of either word "list" or "directory".
Although you can do very simple searches with apropos
, it's a very powerful tool and you can do advanced searches, too. For example, you can use the shell wildcards in your searches with the -w
option. For more info about apropos, go read (you guessed it) its man page.