Monday, September 19, 2011

Controlling the Output of Commands

Sometimes a command will produce more output than can fit on the screen. You can control the
output of a command in a couple of ways.

The more command will show you the contents of a file, one screen at a time. Just press Enter to
see the next screen of the file:

$ more test.txt

The pipe command (|) enables you to pass the output of one command as input to another

In the following example, the | operator takes the ps -ef command’s output (which is the
list of all processes that are currently running on your system) and passes it to the grep command as
a list, to search for all processes that contain the word “Oracle”:

$ ps -ef | grep Oracle

No comments:

Post a Comment