Versão revisada (3ª) de ugly.sh :
#!/bin/bash
{ echo "Domains Hits by IP" ; \
awk '{ print $1 gsub(/^.*:\/\/|\"|\/.*$/,"",$11) "\t" $11 }' $1 | \
sort | \
uniq -c | \
sort -k3,3 -k1,1nr | \
while n="" read a b c; do \
[ $a = 1 ] && p='' || p=s ; \
if [ "$n" = "$c" ] ; then \
echo -n " | $a hit$p $b" ; \
else echo ; \
echo -n "$c $a hit$p $b" ; \
fi ; n="$c" ; \
done ; \
echo ; \
} | \
while read a b ; do \
printf "%-30s %s\n" "$a" "$b" ; \
done
Saída de ./ugly.sh accesslog
:
Domains Hits by IP
networkconfig.com 3 hits 51.254.56.62 | 2 hits 182.180.10.40
networkconfig.net 3 hits 51.254.56.62 | 2 hits 182.180.10.40
Saída de ./ugly.sh log.txt
, (URL do OP para dados: log.txt ):
Domains Hits by IP
- 1 hit 180.76.15.138 | 1 hit 192.243.55.136
www.google.com.pk 3 hits 122.129.73.92
www.networkconfigorchard.com 2 hits 39.46.59.57 | 8 hits 39.46.6.0