From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org)
	by finch.gentoo.org with esmtp (Exim 4.60)
	(envelope-from <gentoo-user+bounces-122899-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1QMK4Z-0005IQ-Bh
	for garchives@archives.gentoo.org; Tue, 17 May 2011 13:12:27 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 4B1501C020;
	Tue, 17 May 2011 13:10:23 +0000 (UTC)
Received: from mail-px0-f182.google.com (mail-px0-f182.google.com [209.85.212.182])
	by pigeon.gentoo.org (Postfix) with ESMTP id 0AA291C020
	for <gentoo-user@lists.gentoo.org>; Tue, 17 May 2011 13:10:22 +0000 (UTC)
Received: by pxi20 with SMTP id 20so304212pxi.13
        for <gentoo-user@lists.gentoo.org>; Tue, 17 May 2011 06:10:22 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:content-type:content-transfer-encoding;
        bh=9CsVj4uq+jzs2EeCSbK0K2xOOBZ0EddYQ+p7Eq9VEA8=;
        b=SIVphuIHf4V1vL1U8jwXkNm660WqfEiryyWQgkcDaYLPTdLwEfZVyUkgtlerk1+z/Y
         ISQlDvFQ8FR6Kgyzk+hlIEdYiWfp4G5WlNfd87/+vcBAb7WeuUl8gxtJfgeyDfVFUbb0
         hEi3qGAxZlwEEbnDeKBDNdhTfW4CHsfjuKPLI=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :content-type:content-transfer-encoding;
        b=nndUm7PyUYg2eralwvrX4Q6lUz2qmeP6Nx9ekfNnnTp/To3krthS67ovO2hqplEubn
         MqCF0MVU0NpDpnB9tAhY54eKLv1qXIzUdYssh0g10wgY8S+8GDZfi9cvuddCTmcHQTap
         /cg8DbOTKWWIHo27ZnWGUD57kaNpxxAk/dodA=
Received: by 10.68.16.201 with SMTP id i9mr1012066pbd.378.1305637822033; Tue,
 17 May 2011 06:10:22 -0700 (PDT)
Precedence: bulk
List-Post: <mailto:gentoo-user@lists.gentoo.org>
List-Help: <mailto:gentoo-user+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-user+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-user+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-user.gentoo.org>
X-BeenThere: gentoo-user@lists.gentoo.org
Reply-to: gentoo-user@lists.gentoo.org
MIME-Version: 1.0
Received: by 10.68.65.168 with HTTP; Tue, 17 May 2011 06:10:02 -0700 (PDT)
In-Reply-To: <BANLkTi=Zp3tQzqH2bcpWwxcYZxHhS1H+4Q@mail.gmail.com>
References: <4DD1AEC8.5010501@earthlink.net> <201105170133.39864.alan.mckinnon@gmail.com>
 <20110517082537.27317958@digimed.co.uk> <BANLkTi=Zp3tQzqH2bcpWwxcYZxHhS1H+4Q@mail.gmail.com>
From: =?UTF-8?Q?Juan_Diego_Tasc=C3=B3n?= <juantascon@gmail.com>
Date: Tue, 17 May 2011 08:10:02 -0500
Message-ID: <BANLkTin-bMi_i-GC-439gj_DGSVUXp6Ncg@mail.gmail.com>
Subject: Re: [gentoo-user] is a nice "place" :-D
To: gentoo-user@lists.gentoo.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: 
X-Archives-Hash: 3a49b784fb37a76e78de94368a0ed1a5

On Tue, May 17, 2011 at 5:43 AM, Pandu Poluan <pandu@poluan.info> wrote:
> On 2011-05-17, Neil Bothwick <neil@digimed.co.uk> wrote:
>> On Tue, 17 May 2011 01:33:39 +0200, Alan McKinnon wrote:
>>
>>> grep "GET /Tmp/Linux/G" | /var/log/apache2/access_log | grep-v <myip> |
>>> \ awk '{print $1}' | sort | uniq | wc
>>>
>>> In true grand Unix tradition you cannot get quicker, dirtier or more
>>> effective than that
>>>
>>
>> awk does pattern matching, o you can ditch the grep stage and use
>>
>> =C2=A0awk '! /myip/ {print $1}'
>>
>> You could use awk to search for the GET patterns too, not only saving ye=
t
>> another process, but making sure that no one else, including you next
>> month, can work out what the command is supposed to do.
>>
>
> Meh, me forgetting what an awk snippet do? Never!
>
> sed ... now that's a wholly different story :-P
>
>> sort -u would save having a separate process for uniq, but I've no idea
>> if it's faster. It's only worth using sort -u if you would use uniq with
>> no arguments.
>>
>
> And you can actually do the 'uniq' or '-u' function within awk. Quite
> easily, in fact.
>
> Here's a sample of awk doing uniq:
>
> awk '!x[$1]++ { print $1 }'
>
> Benefit? It doesn't care if the non-unique lines are one-after-another
> or spread all over the text. The above snippet prints only the first
> occurence. Combine that with a test for match:
>
> awk '!x[$1]++ && $0 ~ /awesome_regex_pattern/ {print $1}'
>
> then with a test for negated match
>
> awk '!x[$1]++ && $0 ~ /awesome_regex_pattern/ && $0 !~
> /more_awesome_regex/ {print $1}'
>
> Rgds,
> --
> Pandu E Poluan - IT Optimizer
> My website: http://pandu.poluan.info/
>
>

I have always wondered if there is a way to do awk '{ print $1}' using
only builtin bash functions when you only have a one line string