man nameofthecommand
So, for example, if help is needed for ls command, type:
man ls (enter)
The help page for man command itself is brought up by:
man man (enter)
Typing
man (enter)
without other parameters displays the required structure of the command. It is not useful for UNIX novices but a helpful memory refreshment for older users.
Beginners often do not know the name of command needed to accomplish their task.
Suppose it is to send a file to the printer. To find the name of the relevant command type
man -k print
The man command with option k prints out one-line summaries from the reference manual that contain the keyword print. This provides at least some particular options to choose from, though it still may take time to find the name that suits the purpose best. Just out of curiosity, it is lpr that does the job.
Most texts consist of more than one pages, but only one page fits the screen. It will be helpful to see one page at the time. Suppose the desired, but long text is in the file named mytext. The command, which allows us to see one screen at the time is more. The format is
more mytext
The output of man -k print is not a file. It is just, say, the screen output.
UNIX allows us to use the output from one command as an input to another command without saving it
into a (temporary) file. To use the result from man -k print as input for the more command type
man -k print more
Notice that man -k print precedes and more, i.e. it is not written instead of the file
name after more! Symbol
is called the pipe. It is the pipe that literally converts
the output of man -k print, or generally of any command preceding
, into a file
accepted by more, or a command following the pipe.
Result from the previous command serves as an input of the second command.
More examples with pipe will be later today and in lab 2, theory of piping is explained in cs354.
Pipe allows chaining of commands into one arbitrary long command. For example,
man -k print sort -u
more
extracts the text on printing, sorts the lines alphabetically according the first character on the line and displays the result page by page on the screen.
Once again, notice that the commands are executed one after the other as they stand on the line. As an exercise, read the man page for sort and see, what option u does.