Getting Help
One of the most important commands in any unix system is man (short for
MANual). It is the interface to an extensive on-line documentation system,
which should have an entry for every command that you can type, and
every function that you can use in a program. To use it, just type man followed
by the name of the command or function. The trouble is, you have to know the name
of the command before you can ask for help on it.
This
is the kind of output that man provides. Pretending that I have forgotten how to use
the sed command, I entered man sed. The complete output is quite long;
this is just the beginning:
SED(1) FreeBSD General Commands Manual SED(1)
NAME
sed - stream editor
SYNOPSIS
sed [-an] command [file ...]
sed [-an] [-e command] [-f command_file] [file ...]
DESCRIPTION
The sed utility reads the specified files, or the standard input if no
files are specified, modifying the input as specified by a list of com-
mands. The input is then written to the standard output.
Although man often says things in a way that defies comprehension, the
essential parts can usually be decrypted with a little effort. The first
section is a nice clear one line description: "sed - stream editor". It doesn't
say what a stream is, or why you might want to edit one, but if you didn't
already know that, you wouldn't be looking up sed, whose whole raison
d'être is stream editing.
The next section is also
fairly clear once you know what to expect. Each line describes a different
way of using the sed command. With the first, after the command "sed", you
can specify a combination of options: "-a", "-n", or "-an". After that, you
must provide a command, and finally you may provide a list of file names.
Just what the options mean, and what the command looks like, will be described
later in the text.
The general pattern is that
anything in square [brackets] is allowed but not required. Command options,
which slightly modify the behaviour of a command, are represented by single letters
and preceeded by a -dash- (specifying "-an" usually means you want both option a
and option n, not just a single option called "an"). The word "file" refers
to any file name, and "..." means that the previous thing may be repeated any
number of times.
So the second version of the command
consists of the word "sed" followed by the same "-a", "-n", or "-an" options as before.
After that if you want to provide a command, you put "-e" in front of it. Then, if
you want a command-file (whatever that may be), you put "-f" in front of it. Then,
as before, you may provide a list of file names.
Right at the end of the very extensive
output that "man sed" provides, which really is hard to read (not just for beginners)
but does tell you almost everything if you can read it, we see:
SEE ALSO
awk(1), ed(1), grep(1), regex(3), re_format(7)
HISTORY
A sed command appeared in Version 7 AT&T UNIX.
STANDARDS
The sed function is expected to be a superset of the IEEE Std1003.2
(``POSIX.2'') specification.
History and Standards are not very useful, but "SEE ALSO" tells you
some other man entries that might be worth looking at. They will be for
other commands that have somewhat similar functions. If you decide that
"regex" sounds interesting, the way to follow the reference is by typing the
command man 3 regex. The 3 in parentheses gives the section of the on-line
manual, which has to be given before the command name when you use man.