Many versions of BSD UNIX include a nice program called
prints the top
(default: 10) lines of a file.
System V or other users without
emulate its behavior with
The easiest way is simply to use
If you want to get fancy, you can use a shell script
to emulate all of the behavior of the BSD
command, including taking an option for the number of lines to be
printed, and printing a separator line if multiple filenames are
specified on the same command line.
The CD-ROM has that script.
Most of it is straightforward.
One interesting part is shown below.
command that prints the separator when more than one
file is shown:
==> $1 <==
inserts the separator before line 1.
quits after the number of lines
(by default, 10) in the
shell variable (
The shell substitutes
with the filename being read.
The double quotes (
) around the
commands let the
shell build the commands on-the-fly before starting