How can I pipe stderr, and not stdout?

First redirect stderr to stdout — the pipe; then redirect stdout to /dev/null (without changing where stderr is going): command 2>&1 >/dev/null | grep ‘something’ For the details of I/O redirection in all its variety, see the chapter on Redirections in the Bash reference manual. Note that the sequence of I/O redirections is interpreted left-to-right, … Read more

How to redirect and append both standard output and standard error to a file with Bash

cmd >>file.txt 2>&1 Bash executes the redirects from left to right as follows: >>file.txt: Open file.txt in append mode and redirect stdout there. 2>&1: Redirect stderr to “where stdout is currently going”. In this case, that is a file opened in append mode. In other words, the &1 reuses the file descriptor which stdout currently … Read more