Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Removing duplicate rows & selecting only latest date Post 302527920 by shash on Monday 6th of June 2011 04:06:56 AM
Old 06-06-2011
Removing duplicate rows & selecting only latest date

Gurus,

From a file I need to remove duplicate rows based on the first column data but also we need to consider a date column where we need to keep the latest date (13th column).

Ex:

Input File:

Quote:
001519831030101654000||||||||||||||||||||||||||20090609|20090609|20090609
001519831030101654999||||||||||||||||||||||||||20090609|20090609|20090609
0015198310301016542R1|0015|001519831030101654||2|2||F|GBP|20050905||20151003|20091103|||0|1,000000|1 ,000000||5,340000|5,340000|||0,000000|||20090609|20090609|20090609
0015198310301016542R1|0015|001519831030101654||2|2||F|GBP|20050905||20151003|20151103|||0|1,000000|1 ,000000||5,340000|5,340000|||0,000000|||20090609|20090609|20090609
0015198310301016542R1|0015|001519831030101654||2|2||F|GBP|20050905||20151003||||0|1,000000|1,000000| |5,340000|5,340000|||0,000000|||20090609|20090609|20090609
0015198310301016543E1|0015|001519831030101654||2|2||V|GBP|20040923||20170903||||0|1,000000|1,000000| |1,500000|1,500000|||0,000000|||20090609|20090609|20090609
0015198310301016543E1|0015|001519831030101654||2|2||V|GBP|20040923||20170903||||0|1,000000|1,000000| |1,500000|1,500000|||0,000000|||20090609|20090609|20090609
Output File:

Quote:
001519831030101654000||||||||||||||||||||||||||20090609|20090609|20090609
001519831030101654999||||||||||||||||||||||||||20090609|20090609|20090609
0015198310301016542R1|0015|001519831030101654||2|2||F|GBP|20050905||20151003|20151103|||0|1,000000|1 ,000000||5,340000|5,340000|||0,000000|||20090609|20090609|20090609
0015198310301016543E1|0015|001519831030101654||2|2||V|GBP|20040923||20170903||||0|1,000000|1,000000| |1,500000|1,500000|||0,000000|||20090609|20090609|20090609
I know how to take out the duplicates but I couldn't figure out selecting the latest date based on column 13th.

Can you please help me?

Thanks
Shash
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Subtract date & time in diferent rows

Hi Friends :) I have a long file having fields in the form : Field1 yy/mm/dd hh:mm:ss Duration(Sec) line 1) 123123 05/11/30 12:12:56 145 line 2) 145235 05/11/30 12:15:15 30 line 3) 145264 05/11/30 13:14:56 178 . . I want to subtract yy/dd/dd hh:mm:ss in line (2) from yy/mm/dd hh:mm:ss in... (1 Reply)
Discussion started by: vanand420
1 Replies

2. Shell Programming and Scripting

To remove date and duplicate rows from a log file using unix commands

Hi, I have a log file having size of 48mb. For such a large log file. I want to get the message in a particular format which includes only unique error and exception messages. The following things to be done : 1) To remove all the date and time from the log file 2) To remove all the... (1 Reply)
Discussion started by: Pank10
1 Replies

3. UNIX for Dummies Questions & Answers

Help selecting some rows with awk

Hi there, I have a text file with several colums separated by "|;#" I need to search the file extracting all columns starting with the value of "1" or "2" saving in a separate file just the first 7 columns of each row maching the criteria, with replacement of the saparators in the nearly created... (2 Replies)
Discussion started by: capnino
2 Replies

4. Shell Programming and Scripting

Removing rows from a file based on date comparison

I have a '|' delimited file and want to remove all the records from the file if the date is greater than a year from sysdate. The layout of the file is as below - xxxxxxxxxxxxxx|yyyyyy|zzzzzz|2009-12-27-00:00| 000000000|N xxxxxxxxxxxxxx|yyyyyy|zzzzzz|2010-01-03-00:00| 000000000|N... (4 Replies)
Discussion started by: Max_2503
4 Replies

5. Shell Programming and Scripting

removing rows from text file older than certain date

Hi I need a way of removing rows from a txt file that are older than 30 days from today, going by the date in column 2, below is an example from my file. I have tried awk but don't have enough knowledge. I would really appreciate some help. 41982,15/07/2010,H833AB/0,JZ,288... (6 Replies)
Discussion started by: firefox2k2
6 Replies

6. UNIX for Dummies Questions & Answers

Selecting the file of latest Date

Hi Folks, I have one query that there is a folder in which daily several logs files are getting created , I reached to that location through putty but what I observer that 10 files of different date are been created with same name , what I need to see is the latest file ...let say the location is ... (5 Replies)
Discussion started by: KAREENA18
5 Replies

7. Shell Programming and Scripting

Removing Duplicate Rows in a file

Hello I have a file with contents like this... Part1 Field2 Field3 Field4 (line1) Part2 Field2 Field3 Field4 (line2) Part3 Field2 Field3 Field4 (line3) Part1 Field2 Field3 Field4 (line4) Part4 Field2 Field3 Field4 (line5) Part5 Field2 Field3 Field4 (line6) Part2 Field2 Field3 Field4... (7 Replies)
Discussion started by: ekbaazigar
7 Replies

8. UNIX for Dummies Questions & Answers

Log file - Delete duplicate line & keep last date

Hello All ! I need your help on this case, I have a csv file with this: ITEM105;ARI FSR;2016-02-01 08:02;243 ITEM101;ARI FSR;2016-02-01 06:02;240 ITEM032;RNO TLE;2016-02-01 11:03;320 ITEM032;RNO TLE;2016-02-02 05:43;320 ITEM032;RNO TLE;2016-02-01 02:03;320 ITEM032;RNO... (2 Replies)
Discussion started by: vadim-bzh
2 Replies

9. Shell Programming and Scripting

Selecting latest entry in the log file

Hi there I am trying to write a script where I will need to look for a specific word in the log file and I am aware this can be done by grep for example. As there will be multiple entries for this I want to grep the last one to enter the log... how would I go about this - would I have to use... (5 Replies)
Discussion started by: simpsa27
5 Replies

10. Shell Programming and Scripting

Size Selecting rows

I have a rather convoluted script that I use to extract information from CSV files: sed '1d' PeakTable.txt | awk -F ',' '!/Ladder/{ if ( $4 > 430 && $4 < 490 && $5 > 45 ) print $2, $5; else print $2, 0 }' | awk '{a+=$2}END{for(i in a){print i, a}}' | sed 's/\(\)\(\) /\10\2 /' | sort | awk... (4 Replies)
Discussion started by: Xterra
4 Replies
PRINTER_SELECT_BRUSH(3) 						 1						   PRINTER_SELECT_BRUSH(3)

printer_select_brush - Select a brush

SYNOPSIS
void printer_select_brush (resource $printer_handle, resource $brush_handle) DESCRIPTION
The function selects a brush as the active drawing object of the actual device context. A brush is used to fill shapes. If you draw an rectangle the brush is used to draw the shapes, while the pen is used to draw the border. If you haven't selected a brush before drawing shapes, the shape won't be filled. PARAMETERS
o $printer_handle -$printer_handle must be a valid printer handle. o $brush_handle -$brush_handle must be a valid brush handle. RETURN VALUES
No value is returned. EXAMPLES
Example #1 printer_select_brush(3) example <?php $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); $pen = printer_create_pen(PRINTER_PEN_SOLID, 2, "000000"); printer_select_pen($handle, $pen); $brush = printer_create_brush(PRINTER_BRUSH_CUSTOM, "c:\brush.bmp"); printer_select_brush($handle, $brush); printer_draw_rectangle($handle, 1, 1, 500, 500); printer_delete_brush($brush); $brush = printer_create_brush(PRINTER_BRUSH_SOLID, "000000"); printer_select_brush($handle, $brush); printer_draw_rectangle($handle, 1, 501, 500, 1001); printer_delete_brush($brush); printer_delete_pen($pen); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); ?> PHP Documentation Group PRINTER_SELECT_BRUSH(3)
All times are GMT -4. The time now is 04:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy