Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

1 Answer 1

up vote 12 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

 
discard

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.