Grep stderr by redirecting stderr to stdout.
my_command 2>&1 | grep --color my_keyword
Grep only stderr by redirecting stderr to stdout and redirecting stdout to /dev/null.
my_command 2>&1 > /dev/null | grep --color my_keyword
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
Comments
Leave a Reply