I want to use `grep` on the `top` utility. Iterating through `top` 5 times, here are my criteria: 

* `grep` two different expressions in a single pass on the `top` output
* expression 1: `grep` for the line on overall cpu usage, then output it to file: ***cpu\_stats.txt***
* expression 2: `grep` for the line on overall memory usage, then output it to file: ***memory\_stats.txt***

Here is what I have now:

```
top -b -n 5 | egrep "\%Cpu\(s\):|KiB Mem :" > both_cpu_and_memory.txt

```

This successfully grabs the desired `top` output, but notice it is putting both expression matches in the exact same file. 

Where I am stuck: I do not know how to, in a single pass, output the matches from one expression to one file, and how to output the matches from the *other* expression to *another* file.

Is this possible? Is it possible to, in one pass, grep multiple expressions, and matches for each expression is outputted to a separate file?