whatis
displays one-line manual page descriptions, intended to give you a general idea of what a program do,
while apropos
searches the manual page names and descriptions, intended to help you to learn what program to use when performing a certain job.
Some examples
Say, I want to know what does df
program do. whatis
gives me answer.
$ whatis df
df (1) - report file system disk space usage
And now, I want to unzip an archive. apropos
gives me some choises for consideration.
$ apropos unzip
bunzip2 (1) - a block-sorting file compressor, v1.0.6
funzip (1) - filter for extracting from a ZIP archive in a pipe
gunzip (1) - compress or expand files
lz (1) - gunzips and shows a listing of a gzip'd tar'd archive
preunzip (1) - prefix delta compressor for Aspell
unzip (1) - list, test and extract compressed files in a ZIP archive
unzipsfx (1) - self-extracting stub for prepending to ZIP archives
uz (1) - gunzips and extracts a gzip'd tar'd archive
UPDATE:
Since both whatis
and apropos
search man database, you can only get info on what's already installed on your system.
A regular expression is not a glob.
I am guessing that you want files that start with "d". In that case, you need:
ls /etc | sort | grep '^d'
What went wrong
How the following statement behaves depends on the files in the current directory:
ls /etc | sort | grep p*
Since it is unquoted, the shell will try to expand the glob p*
, replacing it with whatever file names from the current directory match.
If no file names match, then a literal p*
is passed to grep
. Since grep
expects regular expressions, it interprets p*
to mean zero or more occurrences of the letter p
. Since everything either has a p
or doesn't, that matches everything.
Why would grep d*
list nothing?
That likely means that there was a file name starting with d
in the current directory. Just to be specific, let's say that file's name was dichotomy
. The shell expands d*
to dichotomy
and passes that as the argument to grep
. Thus, the effective command is:
grep dichotomy
That is likely why there were no results when you ran grep d*
.
What happens if multiple files match the d*
glob?
Consider the command:
grep d*
If their are multiple files matching that glob, say dmesg
daemon.log
and dpkg.log
. The shell would expand d*
to the list of those files in alphabetical order (which depends on your locale). This may result in:
grep daemon.log dmesg dpkg.log
This command searches for the presence of the string daemon.log
in the files dmesg
and dpkg.log
. If that string does not occur in those files, no output results.
Best Answer
They are not aliases. Command outputs the full command and comm only the command name, so it is possible that the outputs are different. It all depends on what you want to extract the grep command.
An example:
and the output for the following is empty:
The string
9600
is part of the complete command but the command name.command
, andcmd
are aliases toargs
, with prints the command with all its arguments as string.comm
is a different sorting code that prints only the executable name. Manpage snippet: