John, thanks so much for your script and help. I had to look up the -l
switch to understand how your solution works, and wouldn't have guessed
that this problem involves the end-of-line character. Thanks for
teaching me this concept.

I discovered that I could omit the -l if instead I used:
perl -ne'/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) / && !$x{$1}++ && print
"$1\n"' access_log

which I found a little easier to understand.

Thanks for all your help to all the beginners on this list.

-Kevin

-----Original Message-----
From: John W. Krahn [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 17, 2006 4:12 PM
To: Perl Beginners
Subject: Re: One liner to return unique IPs from web log?

Zembower, Kevin wrote:
> I'm trying to write a perl one-liner to return the unique IP addresses
> from a Apache web log, like this:
> 
> perl -ne 'print if s/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) .*/$1/'
> access.log | nawk '!x[$0]++'

perl -lne'/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) / && !$x{$1}++ && print
$1'


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to