UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 25.2 Four Ways to Skin a cat Chapter 25
Showing What's in a File
Next: 25.4 The "less" Pager: More than "more"

25.3 Using more to Page Through Files

The more utility is light-years ahead of cat (25.2). It lets you read files one page at a time. If you had only cat and wanted to read long files, you'd have to read very fast or have a quick trigger finger (on CTRL-s (41.2)) to stop the text - or get used to reading the last few lines of a file, and no more. In fact, even the most backward versions of more are infinitely preferable to cat for reading a file - so much so that I don't understand why anyone uses cat for this purpose. [I cat tiny files because I have more and less (25.4) set up to clear my screen (with the -c option) before displaying a file. -TC ]

When you start more, it displays the first screen of the file. To move to the next page, press the space bar. You can continue to move forward through the file by pressing the space bar or by pressing RETURN (which moves you forward one line). More recent versions of more allow you to "back up" to previous pages in the file by typing b.

Some other features:

If you invoke more with two or more files, it will display a short header at the beginning of each file. This little nicety is strangely useful. Let's say you want to print all of your .h files with a single command, and you'd like some kind of label before each file. You can use more to create the labels (43.10) for you:

pr lpr 
% more *.h | pr | lpr

(When more isn't writing to a terminal, it doesn't expect you to type anything; it dumps all files to standard output.)

more has a few defects:

A program called less (25.4)less utility solves all of these problems.

[Some versions of System V support a somewhat equivalent program called pg instead of more. And some people like to look at files with a read-only version of vi called view. I prefer more or less. :-) -TOR ]

- ML

Previous: 25.2 Four Ways to Skin a cat UNIX Power ToolsNext: 25.4 The "less" Pager: More than "more"
25.2 Four Ways to Skin a cat Book Index25.4 The "less" Pager: More than "more"

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System