November 21, 2024, 09:44:13 PM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: remove duplicate lines in file  (Read 6870 times)

Offline jack7974

  • New Member
  • Posts: 1
remove duplicate lines in file
« 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

Offline dragoncity99

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 551
Re: remove duplicate lines in file
« Reply #1 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.