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.

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

This question already has an answer here:

I am trying to capture mysql traffic and pass those traffic to strings command as follows:

tcpdump -i any -s 0 -l -w - dst port 3306 | strings

This is working as expected and printing all mysql queries like

select * from mytables
show databases

But when i am trying to redirect the output to a file, its not printing the output to /tmp/out file:

tcpdump -i any -s 0 -l -w - dst port 3306 | strings > /tmp/out

Can someone explain me the behaviour of above command and why it is not redirecting the output to file.

share|improve this question

marked as duplicate by Gilles, Evan Teitelman, jasonwryan, Anthon, bahamat Jul 26 '13 at 7:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 2 down vote accepted

I got the solution:

Actually strings command is buffering. I disabled the buffering by using

stdbuf -i0 -o0 -e0 command

So after changing the whole command to the following, output started going to /tmp/final file.

tcpdump -i any -s 0 -l -w - dst port 3306 | stdbuf -i0 -o0 -e0 strings > /tmp/final 


share|improve this answer
Note that you only need -o0, since you're only redirecting stdout (and -i0 doesn't do anything useful anyway). – Stéphane Chazelas Jul 29 '13 at 15:18

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