Added support for grepping the output of the command.

Fixes #2643