[TriLUG] Small puzzle: Fix my bad one-liner [Was: TLDP]

Carl Schaefer schaefer at trilug.org
Tue Jan 6 16:08:30 EST 2015


> $ sudo gzip -dc 2015/01/www.tldp.org.vhost[123].access.log.20150103.gz |\
>      awk '{addrs[$1]++}END{for(ip in addrs){x++};print x}'

this is a good use of awk, but personally I wouldn't give it high marks
for readability.

A program to do this can be written in any language, of course, but to
me an approach like this feels more "unix-y":

  zcat path/to/logs*.gz | cut -d' ' -f1 | sort -u | wc

which I'd assume to be less efficient than a program in awk or
whatever...
Carl


More information about the TriLUG mailing list