User guide
12.5 Using Pipes and grep to Filter Output
To search for specific values in a device, use a pipe with the grep command.
A pipe ( | ) enables the output of one command to be the input for the next
command without creating an intermediate file. The grep command filters its
input according to the command argument. Because the grep command requires
input, a pipe is used to channel the output of the examine command into the
grep command.
The following example uses grep to search for a pattern in memory. In this case,
grep parses all the output lines from the examine command, but only permits
lines that contain abcdef12 to reach the display. The grep command also can
be used to search for patterns that do not match the model provided; that is, it
searches for every line that does not contain the input pattern. The following
example sets up the memory and then uses grep to filter the output.
>>> d pmem:3fff000 0 -n 8 # Clear some memory.
>>> d 3fff020 abcdef12 # Drop in a target.
>>> e 3fff000 -n 8 # Display memory.
pmem: 3FFF000 0000000000000000
pmem: 3FFF008 0000000000000000
pmem: 3FFF010 0000000000000000
pmem: 3FFF018 0000000000000000
pmem: 3FFF020 00000000ABCDEF12
pmem: 3FFF028 0000000000000000
pmem: 3FFF030 0000000000000000
pmem: 3FFF038 0000000000000000
pmem: 3FFF040 0000000000000000
>>> e 3fff000 -n 8 | grep ABCDEF12 # Display only lines with ABCDEF12.
pmem: 3FFF020 00000000ABCDEF12
12.6 Using I/O Redirection (>)
By default, output goes to the console. You can redirect output to other devices
or files by using the redirection operator, >. In the following example, the output
of an examine command is redirected to file foo, which is created dynamically
out of the console’s memory heap. The console cat command, similar to the
OpenVMS copy command, is used in this example to display the contents of the
new file. The rm command, similar to the OpenVMS delete command, is used to
remove the foo file.
12–12 Console Primer