I want to extract the timestamp of the packets using tcpdump and put it into a file, in such a way that the latest timestamp replaces the first line (which either is empty or contains the the timestamp of the second-last packet). Its necessary that the file should only have a 1 line entry ie. the timestamp of the latest packet.
This is what I did:
sudo tcpdump -i eth0 -l | cut -d . -f1 > test.txt
cat test.txt
16:08:04
16:08:05
16:08:05
16:08:05
16:08:05
16:08:05
16:08:05
16:08:05
But what I want is only the latest timestamp:
cat test.txt
16:08:05
Any Ideas?