Dark Launch

Bash grep stderr and stdout

Grep stderr by redirecting stderr to stdout.

Bash
my_command 2>&1 | grep --color my_keyword

Grep only stderr by redirecting stderr to stdout and redirecting stdout to /dev/null.

Bash
my_command 2>&1 > /dev/null | grep --color my_keyword
Bash
php -r 'fwrite(STDOUT, "stdout\n");fwrite(STDERR, "stderr\n");' | grep --color std
php -r 'fwrite(STDOUT, "stdout\n");fwrite(STDERR, "stderr\n");' 2>&1 | grep --color std
php -r 'fwrite(STDOUT, "stdout\n");fwrite(STDERR, "stderr\n");' 2>&1 > /dev/null | grep --color std