Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Using a pipe z/OS UNIX System Services User's Guide SA23-2279-00 |
|
The output from one command can be piped in as input to
the next command. Two or more commands linked by a pipe (|) are called
a pipeline. A pipeline is written as:
You
enter the commands on the same line and separate them by the "or-bar"
character |.Many z/OS® shell
commands are well suited to being used in a pipeline. For example,
the grep command searches for a particular
string in input from a file or standard input (the keyboard). A command
such as:
displays all the cp commands
recorded among the 16 most recently recorded commands in your history
file. The command:
uses ls to
obtain information about the contents of the working directory and
uses grep to search through this information
and display only the lines that contain the string Jan.
The pipeline displays the files that were last changed in January.A filter is a command that can read from standard input
and write to standard output. A filter is often used within a pipeline.
In the following example, grep is the filter:
lists
all of your processes that are currently active in the system and
pipes the output to grep, which searches
for every instance of the string cc. The
output from grep is then piped to wc,
which counts every line in which the string cc occurs
and sends the number of lines to standard output. |
Copyright IBM Corporation 1990, 2014
|