[TriLUG] Small puzzle: Fix my bad one-liner [Was: TLDP]
Warren Myers
volcimaster at gmail.com
Wed Jan 7 13:24:22 EST 2015
This is what I use (on non-gz'd files) to check for unique IPs across all
domains hosted on my server:
for f in *access_log; do echo -e `cut -d ' ' -f1 $f | sort -u | wc -l` "\t
$f" ; done
On Tue, Jan 6, 2015 at 4:08 PM, Carl Schaefer <schaefer at trilug.org> wrote:
> > $ 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
> --
> This message was sent to: Warren <volcimaster at gmail.com>
> To unsubscribe, send a blank message to trilug-leave at trilug.org from that
> address.
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> Unsubscribe or edit options on the web :
> http://www.trilug.org/mailman/options/trilug/volcimaster%40gmail.com
> Welcome to TriLUG: http://trilug.org/welcome
>
--
*Warren Myers*
http://antipaucity.com
http://twitter.com/warrenmyers
http://www.linkedin.com/in/warrenmyers
https://www.digitalocean.com/?refcode=d197a961987a
TXT WMYERS to 50500 | http://contxts.com
More information about the TriLUG
mailing list