unix - Search a log file for total count of unique ips -


i'm using following format counts of how many times unique ips hit website.

search log file total count of unique ips

zcat *file* | awk '{print $1}' | sort | uniq -c | sort -n 

this gives me list of ips , it's occurrence.

1001 109.165.113.xxx 1001 178.137.88.xxx 1001 178.175.13.xxx 1001 81.4.217.xxx 1060 74.122.180.xxx 1103 67.201.52.xxx 1203 81.144.138.xxx 1670 54.240.158.xxx 1697 54.239.137.xxx 2789 39.183.147.xxx 4630 93.158.143.xxx 

what want find out simple , if can done on single command line.

i want count of list. above example. want buffer tell me 11. thought use second awk command count unique occurrence of 2nd output guess cannot use awk twice in single command line.

obviously can output above log file , run second awk command count unique occurrence of 2nd field(ips) hoping done in single command.

you might want:

zcat ... | awk '{cnt[$1]++} end{for (ip in cnt) {unq++; print cnt[ip], ip}; print unq+0}' 

if have gnu awk can add begin{procinfo["sorted_in"]="@ind_num_asc"} @ front loop output sorted, see http://www.gnu.org/software/gawk/manual/gawk.html#controlling-scanning.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -