Lets say I have millions of packets to look through and I want to see how many times a packet was sent to a certain port number.
Here are some of the packets:
See uniq -c. You'll want to pull out the bit you want, sort the result, pipe thru uniq, sort the output. Something like this maybe:
egrep '\.[0-9]+:' output.txt | sort | uniq -c | sort -nr
Clarification: I've used grep here because it's not clear what your output.txt format looks like, but you'll want to actually cut out the port number bit, perhaps via cut
or awk
.
Edit: To get the port, you can cut once on a period and then again on a colon:
cut -d. -f10 < output.txt | cut -d: -f1
(Or any one of a dozen other ways to accomplish the same thing.) That will give you an unsorted list of ports. Then:
cut -d. -f10 < output.txt | cut -d: -f1 | sort | uniq -c | sort -nr