Linux Forums - Linux Help,Advice & support community:LinuxSolved.com

Linux in General => Linux Development & Programming => Topic started by: jack7974 on April 25, 2008, 04:09:28 AM

Title: remove duplicate lines in file
Post by: jack7974 on April 25, 2008, 04:09:28 AM
Hi
Having a file as follows

Code: [Select]
==================================================
Date           Time         error code      server
======================================================
12-29-08    10:10        121221          server A
12-29-08    10:12        121221          server A
12-29-08    10:10        121221          server B
12-29-08    10:10        121221          server B

Need to remove the duplicate lines with the following conditions
if date=12-29-08 and server=server A .
Must delete the line with old time and keep the latest.

Anyone can suggest

Thanks in advance
Title: Re: remove duplicate lines in file
Post by: dragoncity99 on December 03, 2009, 12:00:09 PM
It might be difficult if usign current timestamp. Probalby you need to convert it to time in terms of Epoch time since the number is incremental and sort-able.

Otherway is to remove the ":" and do sorting get the last ones.