remove duplicate entries from dhcp.lease


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers remove duplicate entries from dhcp.lease
# 1  
Old 11-22-2011
remove duplicate entries from dhcp.lease

Hi,

I have to parse the dhcp.lease file and have to keep the most recent entry and remove the rest and also the number of lines between any two leases might not always be the same.

eg:


lease 5.5.5.252 {
starts Wed Jul 27 09:48:39 2011
ends Wed Jul 27 21:48:39 2011
tstp Wed Jul 27 21:48:39 2011
binding state active;
next binding state free;
hardware ethernet 00:25:90:0a:95:e1;
uid "\001\000%\220\012\225\341";
}
lease 5.5.5.253 {
starts Wed Jul 27 11:18:04 2011
ends Wed Jul 27 23:18:04 2011
binding state active;
next binding state free;
hardware ethernet 00:1b:54:c9:e9:fd;
uid "\001\000\033T\311\351\375";
}
lease 5.5.5.252 {
starts Wed Jul 27 11:23:32 2011
ends Wed Jul 27 23:23:32 2011
binding state active;
next binding state free;
hardware ethernet 00:25:90:0a:95:e1;
uid "\001\000%\220\012\225\341";
}
lease 5.5.5.253 {
starts Wed Jul 27 11:24:35 2011
ends Wed Jul 27 23:24:35 2011
tstp Wed Jul 27 23:18:04 2011
binding state active;
next binding state free;
hardware ethernet 00:1b:54:c9:e9:fd;
uid "\001\000\033T\311\351\375";
}
lease 5.5.5.253 {
starts Wed Jul 27 11:27:56 2011
ends Wed Jul 27 23:27:56 2011
binding state active;
next binding state free;
hardware ethernet 00:1b:54:c9:e9:fd;
uid "\001\000\033T\311\351\375";
}



should give

lease 5.5.5.252 {
starts Wed Jul 27 11:23:32 2011
ends Wed Jul 27 23:23:32 2011
binding state active;
next binding state free;
hardware ethernet 00:25:90:0a:95:e1;
uid "\001\000%\220\012\225\341";
}

lease 5.5.5.253 {
starts Wed Jul 27 11:27:56 2011
ends Wed Jul 27 23:27:56 2011
binding state active;
next binding state free;
hardware ethernet 00:1b:54:c9:e9:fd;
uid "\001\000\033T\311\351\375";
}

as the output. Please help

---------- Post updated at 08:05 AM ---------- Previous update was at 08:02 AM ----------

The most recent entry is always the last occurence. I tried an earlier post on this forum but was not able to change it to suite my requirements. Any help is sincerely appreciated
# 2  
Old 11-22-2011
Quote:
Originally Posted by bitspradp
The most recent entry is always the last occurence. I tried an earlier post on this forum but was not able to change it to suite my requirements. Any help is sincerely appreciated
If you know that the most recent entry is always the last occurence then its easier...than if they were randomly distributed in the file.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove columns with duplicate entries

I have a 13gb file. It has the following columns: The 3rd column is basically correlation values. I want to delete those rows which are repeated between the columns: A B 0.04 B C 0.56 B B 1 A A 1 C D 1 C C 1 Desired Output: (preferably in a .csv format A,B,0.04 B,C,0.56 C,D,1... (3 Replies)
Discussion started by: Sanchari
3 Replies

2. Shell Programming and Scripting

Remove duplicate entries based on the range

I have file like this: chr start end chr15 99874874 99875874 chr15 99875173 99876173 aa1 chr15 99874923 99875923 chr15 99875173 99876173 aa1 chr15 99874962 99875962 chr15 99875173 99876173 aa1 chr1 ... (7 Replies)
Discussion started by: raj_k
7 Replies

3. Shell Programming and Scripting

Remove duplicate entries from the same line

Hello, I have a file which have several duplicate entries on the same line: File ID source 1 GM GF GM 2 GM GF GM GF GM GF GM GF GM GF 3 GM GF GM SF GM GF GM SF 4 FF FF FF FF 5 FF GM FF ... (2 Replies)
Discussion started by: nans
2 Replies

4. Solaris

Solaris 10- DHCP lease time increase

HI Admins, can anyone tell me how can I increase the lease time in Solaris 10. I want to use that dhcp address for 4 weeks. (2 Replies)
Discussion started by: snchaudhari2
2 Replies

5. Shell Programming and Scripting

Request to check:remove entries with duplicate numbers in first row

Hi I have a file 1 xyz 456 1 xyz 456 1 xyz 456 2 abc 8459 3 gfd 657 4 ghf 658 4 ghf 658 I want the output 1 xyz 456 2 abc 8459 3 gfd 657 4 ghf 658 (3 Replies)
Discussion started by: manigrover
3 Replies

6. Red Hat

DHCP lease problem

Hi frnds I am testing DHCP server on vmware.I have two REDHAT 9 vmware machine.DHCP is installed on one machine and second machine is using as a client .I have configured DHCP with Ip Address ,Mask and Gateway.But client machine is not getting ip address.When i type ifconfig command on client it... (6 Replies)
Discussion started by: Vaibhav.T
6 Replies

7. IP Networking

DHCP lease under SuSE is not working., limited at 10 minutes

Hi, I got a strange issue here: We are using ISC DHCP v4 which is default in Open SuSE 11.4. These two options 'default-lease-time' and 'max-lease-time' are set in all subnets, with values between 43200 (12 hours) to 518400 (144 hours). See partial dhcpd.conf below please. Now the lease... (5 Replies)
Discussion started by: aixlover
5 Replies

8. UNIX for Advanced & Expert Users

DHCP lease under SuSE is not working. Why?

Hi, I got a strange issue here: We are using ISC DHCP v4 which is default in Open SuSE 11.4. These two options 'default-lease-time' and 'max-lease-time' are set in all subnets, with values between 43200 (12 hours) to 518400 (144 hours). See partial dhcpd.conf below please. Now the lease time... (0 Replies)
Discussion started by: aixlover
0 Replies

9. Shell Programming and Scripting

Need to delete duplicate lease entry

Hi *, I need to delete duplicate lease entries in file according to MAC/IP. I'm having tempfile which contains many lease info and need to have one entry for each IP(not more than that), if it contains more than one entry for same set, need to be deleted that entry... EX: lease... (4 Replies)
Discussion started by: SMNK
4 Replies

10. Shell Programming and Scripting

remove duplicate

i have a text its contain many record, but its written in one line, i want to remove from that line the duplicate record, not record have fixed width ex: width = 4 inputfile test.txt =abc cdf abc abc cdf fgh fgh abc abc i want the outputfile =abc cdf fgh only those records can any one help... (4 Replies)
Discussion started by: kazanoova2
4 Replies
Login or Register to Ask a Question