From: Todd on
On 06/11/2010 08:54 PM, unruh wrote:
> On 2010-06-12, Todd<todd(a)invalid.com> wrote:
>> Hi All,
>>
>> I have a file:
>>
>> abc
>> def
>> ghi
>> abc
>> jkl
>>
>> How do I remove the second (duplicate) "abc" wih
>> a shell command?
>
> sort -u?
> Although that will change the order of the lines. (well not in this
> case, but in general)
>
>>
>> May thanks,
>> -T

$ cat eraseme.txt | sort -u
abc
def
ghi
jkl

This I like. I typically want to both sort and remove
duplicates. And it is easy to understand too.

Thank you!,
-T
From: Todd on
On 06/12/2010 11:48 AM, Kenny McCormack wrote:
> In article<V6Odnf1CUvxDXI7RRVn_vwA(a)giganews.com>,
> John Reiser<jreiserfl(a)comcast.net> wrote:
>>> abc
>>> def
>>> ghi
>>> abc
>>> jkl
>>>
>>> How do I remove the second (duplicate) "abc" wih
>>> a shell command?
>>
>> The shell command 'uniq' has been around for more than 30 years.
>
> 'uniq' has nothing to do with the instant problem.
>
> 'sort -u' is tangentially related, although unlikely to be what the OP
> wants.
>

man uniq...
-u, --unique
only print unique lines


$ cat eraseme.txt | uniq -u
abc
def
ghi
abc
jkl


Not so much. :'(

Thank you anyway.
-T
From: pk on
Todd wrote:

> On 06/12/2010 11:48 AM, Kenny McCormack wrote:
>> In article<V6Odnf1CUvxDXI7RRVn_vwA(a)giganews.com>,
>> John Reiser<jreiserfl(a)comcast.net> wrote:
>>>> abc
>>>> def
>>>> ghi
>>>> abc
>>>> jkl
>>>>
>>>> How do I remove the second (duplicate) "abc" wih
>>>> a shell command?
>>>
>>> The shell command 'uniq' has been around for more than 30 years.
>>
>> 'uniq' has nothing to do with the instant problem.
>>
>> 'sort -u' is tangentially related, although unlikely to be what the OP
>> wants.
>>
>
> man uniq...
> -u, --unique
> only print unique lines
>
>
> $ cat eraseme.txt | uniq -u
> abc
> def
> ghi
> abc
> jkl
>
>
> Not so much. :'(

man uniq

....
Filter adjacent matching lines ...
^^^^^^^^

From: Kenny McCormack on
In article <hv0ooj$rug$2(a)speranza.aioe.org>, Todd <todd(a)invalid.com> wrote:
....
>$ cat eraseme.txt | uniq -u
>abc
>def
>ghi
>abc
>jkl
>
>
>Not so much. :'(
>
>Thank you anyway.

That's the point of my post - that 'uniq' does not have anything to do
with your problem, since uniq only works on adjacent duplicates. So,
you and I are on the same side of this one.

Your AWK solution is on the money. That'd be how I'd do it.

--
> No, I haven't, that's why I'm asking questions. If you won't help me,
> why don't you just go find your lost manhood elsewhere.

CLC in a nutshell.

From: Kenny McCormack on
In article <hv0oj4$rug$1(a)speranza.aioe.org>, Todd <todd(a)invalid.com> wrote:
>On 06/11/2010 08:54 PM, unruh wrote:
>> On 2010-06-12, Todd<todd(a)invalid.com> wrote:
>>> Hi All,
>>>
>>> I have a file:
>>>
>>> abc
>>> def
>>> ghi
>>> abc
>>> jkl
>>>
>>> How do I remove the second (duplicate) "abc" wih
>>> a shell command?
>>
>> sort -u?
>> Although that will change the order of the lines. (well not in this
>> case, but in general)
>>
>>>
>>> May thanks,
>>> -T
>
>$ cat eraseme.txt | sort -u
>abc
>def
>ghi
>jkl
>
>This I like. I typically want to both sort and remove
>duplicates. And it is easy to understand too.
>
>Thank you!,
>-T

That works, too. Note that we had almost a dozen posts to this thread
and yet no one has mentioned the UUOC...

--
Just for a change of pace, this sig is *not* an obscure reference to
comp.lang.c...