Pipeing linux commands and their output

As a system administrator, I always worry about certain things, like who\'s doing what, what processes are running, what the network traffic looks like, etc.  One day I decided to create a simple alias that would combine all the commands I wanted into one big chunk of information.  Then I realized that it wouldn\'t all fit into one screen.
Fortunately I knew how to group all of the commands together, so the \"more\" command could handle them as one set of input.

First, here\'s the wrong way to try to page a sequence of four commands:

     date; netstat -i; whodo; ps -ef | more

The only command that gets paged properly here is the \"ps -ef\" command --the rest of them scroll off the screen before you can read them.

Here\'s the correct way to page four commands so they\'re all controlled by \"more\":

      (date; netstat -i; whodo; ps -ef) | more

Once you find the commands you want to group together, you can combine them into an alias or shell program.  I recommend a shell program for this, because a few \"echo\" statements sure make it easier to see where one command ends and the next command begins!

This site uses Akismet to reduce spam. Learn how your comment data is processed.