Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to run strace trough ccze, and the pipe doesn't work as expected.

The command-line I'm running to test is sudo strace -p $(pgrep apache2) | grep open, and all lines are output, ignoring grep.

Is there something special about strace that causes this behavior?

share|improve this question
up vote 27 down vote accepted

strace prints its traces on standard error, not on standard output. That's because it's common to want to redirect the standard output of the program, but usually not a problem that strace's stderr and the program's stderr are mixed.

So you should redirect strace's stderr to stdout to be able to pipe it:

sudo strace -p $(pgrep apache2) 2>&1 | grep open

except that what you're really looking for is

sudo strace -p $(pgrep apache2) -e open
share|improve this answer
it works!! thank you! - I wasn't actually trying to look only at open calls, I just put that as an example, what I'm really trying to do is color highlighting – Andrei Sep 15 '12 at 0:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.