How can I have tcpdump write to file and standard output the appropriate data?
Here's a neat way to do what you want:
tcpdump -w - | tee somefile | tcpdump -r -
What it does:
-
-w -
tellstcpdump
to write binary data tostdout
-
tee
writes that binary data to a file AND to its ownstdout
-
-r -
tells the secondtcpdump
to get its data from itsstdin
Since tcpdump 4.9.3 4.99.0, the --print
option can be used:
tcpdump -w somefile --print
Wednesday, December 30, 2020, by [email protected], denis and fxl.
Summary for 4.99.0 tcpdump release
[...]
User interface:
[...]
Add --print, to cause packet printing even with -w.