|
|
|
Beep! Beep! Is that my Pager?Copyright © 1998 Chris Coleman
When suddenly! from the back corner of the room, you hear... the Narrators voice? "Is there no hope in sight?"
You shake yourself and realize that you have fallen into a somewhat disturbing slumber. You clean the drool off your keyboard and go to work trying to find out what a pager might be. A pager is a program that pauses your screen output at the end of a page. PAGER is in an environment variable in your shell configuration file that determines which pager is used by default. Several programs use the value from PAGER. The only one we are going to look at is man. There are several other programs that don't use a pager that we will need to add paging services to by hand. In this article we will learn how to
Selecting a Pager:There are two main pagers: more and less. Each one is pretty much like the other. Less is reported to have more features than more. Yet, I have heard that more is a version of less hacked to act like more. So I guess, that less has more, but more is less. Either way, when you figure out which one you want, you need to edit your shell configuration file. I just noticed the existence of "most" in the ports collection, so I know there are still other pagers available.You can determine which shell you are using by typing: echo $SHELL The default shell on BSD is the C shell, or csh. I have
installed an enhanced C Shell called tcsh. Most Linux users
will be more familiar with the Bourne Again Shell, or bash.
The C shells will use .cshrc as the configuration file, and the
Bourne Shells will use .profile as their configuration file.
vi .cshrc The new value of PAGER has now been saved so it will be used each time we login or start a new shell. However, it hasn't changed our immediate environment. To change it to less we would type: setenv PAGER less This would take effect immediately. Now when we read the man pages, it will use the pager we just specified to control the screen output. Reading the Manual PagesThe BSD manual pages (or manpages as they are often called) describe nearly every user command, administrative command, library call, and file format used on the system, plus some other informative tidbits (like a built-in ASCII table). Each page includes a summary, lists all the options available with the command, and generally goes into detail about the command and refers you to related pages.To access the Manual Pages, type in man followed by the command you are interested in learning about. To learn about more for example, you would type: man more
Since we are reading the man page on more, we discover that pressing these keys will result in the following:
Stopping Speeding Bullets.You can add a pager to the output of any program that displays to the standard output (your current screen or window). This is accomplished by piping the output of your program through your pager of choice using the '|' (pipe) operator. The pipe operator feeds the output of one program to the input of another program. This way commands such as cat, ls, dmesg, and last (that normally run at sub light speeds) can be slowed down. And its easy, just append '|' and the pager to any command that needs it. For example:dmesg | more This will re-display the your server boot up messages.
cat /var/log/messages | more I can't think of any reason to actually use cat in this instance, since more would do a better job by itself. Try it this way: more /var/log/messages This is quite useful when you want to read a very large text document. I have only listed the very basic commands for the most common pagers. There are myriads of command line options and built-in features available, such as searching and command execution. Most of these are patterned after vi commands. If you need more information read the man pages on each of the various pagers.
Chris Coleman chrisc@vmunix.com
|
||