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 have a tcpdump command:

tcpdump -i wlan0 dst port 80 and ! dst 192.168.1.201 and ! src 192.168.1.201 -vvv -s0 -w proba.txt

Which gives the following output:

root@SERVER:/tmp# egrep "GET|Host:" proba.txt | awk 'BEGIN {FS=" "}{print $2}'
emaffia.hu
/
google.hu
/
www.google.hu
emaffia.hu
/textinputassistant/tia.png
www.google.hu
/logos/2011/pierre_de_fermat-2011-hp.jpg
www.google.hu
/gb/images/b_8d5afc09.png
ssl.gstatic.com
/favicon.ico
www.google.hu
/
hwsw.hu
/js/mootools-1.2.5.1-more.js
www.hwsw.hu

How can I modify these lines to get this output?:

emaffia.hu/
google.hu/
www.google.hu
emaffia.hu/textinputassistant/tia.png
www.google.hu/logos/2011/pierre_de_fermat-2011-hp.jpg
www.google.hu/gb/images/b_8d5afc09.png
ssl.gstatic.com/favicon.ico
www.google.hu/
hwsw.hu/js/mootools-1.2.5.1-more.js
www.hwsw.hu

Is it possible?

share|improve this question

2 Answers 2

You might want to look into tcpflow instead, it decodes the protocol and produces human readable text streams. By default they go to a file but the -c flag prints it on the console. tcpflow is one of my favorite hidden gems.

share|improve this answer

You pipe the output of your parsing command though sed - like this:

 egrep "GET|Host:" proba.txt | awk 'BEGIN {FS=" "}{print $2}' | sed ':a;N;$!ba;s/\n\//\//g'
share|improve this answer

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.