Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Sep 2007 11:06:12 -0700
From:      "Kurt Buff" <kurt.buff@gmail.com>
To:        "Jerry McAllister" <jerrymc@msu.edu>
Cc:        questions@freebsd.org
Subject:   Re: Scripting question
Message-ID:  <a9f4a3860709131106h688149fr3b210753c07c86aa@mail.gmail.com>
In-Reply-To: <20070913175510.GA78984@gizmo.acns.msu.edu>
References:  <a9f4a3860709131016w54c12b6fy94fc2b0f286aea3d@mail.gmail.com> <20070913172001.GA78799@gizmo.acns.msu.edu> <a9f4a3860709131032q21bfefc2hf8d78cae53637576@mail.gmail.com> <20070913175510.GA78984@gizmo.acns.msu.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On 9/13/07, Jerry McAllister <jerrymc@msu.edu> wrote:
>
> First, please always make sure your responses go to the list.
> It is both list etiquette and of practical value.  Follow-ups to
> only an individual may not reach the person who can provide real help.
>
> Most Email clients have a group reply which will do the trick.

Yup - that's my fault, and contrary to my intent - I was using the web
interface, and it's too easy to just hit the reply button instead of
"reply to all"  - mea culpa.



> On Thu, Sep 13, 2007 at 10:32:34AM -0700, Kurt Buff wrote:
>
> > On 9/13/07, Jerry McAllister <jerrymc@msu.edu> wrote:
> > > On Thu, Sep 13, 2007 at 10:16:40AM -0700, Kurt Buff wrote:
> > >
> > > > I'm trying to do some text file manipulation, and it's driving me nuts.
> > > >
> > > > I've got a sorted file of SMTP addresses, and want to eliminate the
> > > > lines that are the same up to a space character within the line.
> > > >
> > > > Example:
> > > >
> > > > kurt.buff@gmail.com NO
> > > > kurt.buff@gmail.com OK
> > > >
> > > > The above lines *both* need to be eliminated from output - I don't
> > > > want the first or second of them, I want them both gone.
> > > >
> > > > I've looked at sort and uniq, and I've googled a fair bit but can't
> > > > seem to find anything that would do this.
> > >
> > > Seems like this is right up sort's alley.
> > > Is the first string always separated from the rest by white space
> > > or does your first string sometimes include white space.
> > >
> > > ////jerry
> >
> > The only space is the one separating the SMTP address from the OK or NO.
>
> Then you should be able to tell it to sort on the first token in
> the string with white space as a separator and to eliminate
> duplicates.   It has been a long time since I had need of sort. I
> don't remember the arguments/flags but am sure that type of thing can be done.

Tried that, and it doesn't work the way I expect, or else I'm doing it
wrong, which is definitely possible.

My first difficulty is that I can't figure out how to specify the
space as the field delimiter, assuming that -t is the correct
parameter for that. I've tried specifying '@' for -t, but that doesn't
work either.

Next, my suspicion is that the -u parameter will simply output the
first line of a set of non-unique lines, which is what it does
normally - it doesn't seem to eliminate all non-unique lines, it just
makes the first line the unique one.

Am I making sense?

Kurt



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a9f4a3860709131106h688149fr3b210753c07c86aa>