\subsection{More or Less
Or, ``$|$''---What Is This Symbol For, Anyway?}

{\LARGE \bf Anybody have any good ideas on what we can do to this
chapter to make it worthwhile?}

{\tt more} and {\tt less} are pagers---given a
filename, they show you a screenful of text.  When you finish reading
that screen, you hit the spacebar, and they display the next screen.
They make life at $\geq$ 9600 baud much easier.

{\tt more} is the Berkeley standard program.  The spacebar prints the
next screen; the return key prints the next line, and ``b'' puts you
back a page.  Its syntax is {\tt more} {\it filename}.  Inside {\tt
more}, the letter h will print a help menu.  Do a {\tt man more} for
further information.

{\tt less} is found in {\it /mit/watch\-maker/vaxbin} or {\it
/mit/watch\-maker/rtbin}.  It
behaves much like {\tt more}, as it was written to replace {\tt more} at
a time when more could only go forward, and not backwards.  It has many
more options than {\tt more}, but that makes it correspondingly slower.

These programs are also useful to page through the output of a program,
when it is more than one screen long.  This uses the ``pipe'' symbol,
``$|$''.  For example, {\tt ls -l /bin | more} take the output of the ls
command and uses {\tt more} to show it to you a page at a time.

``$|$'' is generally used to take the output of one command and make it
the input to another.  For instance, assume that you have a long list of
names in a file called {\it direct.names}, and you want to sort them in
alphabetical order.  You also want to make sure that each name is in the
file only once.  You could say
\newline {\tt sort direct.names > temp} \newline
and then say
\newline {\tt uniq temp > direct.names} \newline
but that's rather messy, and leaves
a temp file lying around.  The shortest way to do it is
\newline {\tt sort direct.names | uniq > temp ; mv temp direct.names}\newline
Do {\em not} try to do this by typing
\newline {\tt sort direct.names | uniq > direct.names} \newline
since it will {\bf destroy} the file {\bf direct.names}.  The shell,
upon seeing the redirection to {\bf direct.names} opens and truncates
the file immediately, {\em before} the sort command reads it.

There are other interesting output commands.  {\tt cat -n} prints each
line of a file and numbers the lines.  Its syntax is {\tt cat -n} {\it
filename}.  {\tt pr} divides your output into page-sized chunks and puts
a header on each page.  Nice for printing an unformatted file.  {\tt lpr
-p} {\it filename} does the same thing that {\tt pr} {\it filename} {\tt
| lpr} does; paginate the file with pr and send it to the printer [Note
that the {\tt -p} {\em must} be lowercase, {\tt -P} is used to specify a
printer name].

% Local Variables:
% mode: TeX
% version-control: t
% make-backup-files: t
% End:
