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've got a process that I want to inspect with strace, but since it's printing out a lot of stuff, I would like to sample only a few lines every X seconds from it. Is there any way of doing that with bash or similar?

For example:

strace -p 123456 | "print out most recent 80 lines every 2 seconds"
share|improve this question
up vote 3 down vote accepted


strace -p $PID >$PID.log &
watch tail -n80 $PID.log >$PID-sample.log &
tail -f $PID-sample.log

or just watch tail -n$LINES $PID.log if you don't need to scroll back through the sampled log.

share|improve this answer

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.