On 6/8/06, Michael O'Keefe <[EMAIL PROTECTED]> wrote:
Michael O'Keefe wrote:
> James Keeline wrote:
>
>> --- Richard Ernst <[EMAIL PROTECTED]> wrote:
>>
>>> 6/8/2006,8:24:25,VENUS,LAN,0AADAMS,Desktop,10.66.6.123,x86 Family 15
>>> 5/31/2006,9:14:42,JUPITER,LAN,0AADAMS,Desktop,10.66.6.123,x86 Family
>>> 15 Model 2 Stepping 7,2400 MHz,255 Mb
>>> 6/5/2006,10:40:25,JUPITER,LAN,0ACCTGXTRA-2K,Desktop,10.66.6.99,x86
>>> Family 6 Model 7 Stepping 3,548 MHz,256 Mb
>>> 6/8/2006,9:14:49,VENUS,LAN,0ALADEN,Desktop,10.66.6.57,x86 Family 6
>>> Model 8 Stepping 3,863 MHz,383 Mb
>>> 6/7/2006,9:06:00,VENUS,LAN,0ALADEN,Desktop,10.66.6.57,x86 Family 6
>>> Model 8 Stepping 3,863 MHz,383 Mb
>>> I looked at uniq, but I couldn't find a way to just compare a certain
>>> field and ignore the rest.
>>
>>
>> Do you want to see the entire line or just the unique hostname value
>> in the 5th field?  If you
>> only wanted a list of the unique hostnames you could use awk:
>>
>> cat input_file | awk -F',' '{ print $5; }' | sort | uniq
>> cat input_file | cut -d',' -f5 | sort | uniq
>>
>> If you wanted to see the first line in the file for each of these
>> hostnames then that might
>> require a bit more cleverness.
>>
>> I'll be interested to see what other suggestions you receive.
>
> sort -t, -k 5 | sed 's/,/ /g' | uniq -f4 -w13
>
> I picked -w13 becoz it was the largest hostname in your sample.
> Change to suit....

Want to contribute to OpenSource and become immortal !?!
Add a -t flag to uniq ! it only deals with whitespace separation, hence
the sed :(



$ gawk -F"," '{ array[$5]=$0} END {for (i in array) print array[i] }'
input_file

Using "," as field separator, store the whole input line into array
elements indexed by field 5, then print out the contents of the array.
This gives you the last occurrence of each unique value.  With
slightly more work you could get the first occurrence.

$ sort -t"," -k5,5 -u input_file

Sort the input with field separator "," field 5 only, report unique values.

TIMTOWTDI

   carl
--
   carl lowenstein         marine physical lab     u.c. san diego
                                                [EMAIL PROTECTED]

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-newbie

Reply via email to