I have to sort a file based on the first column for ex - 00150366 in the bold pattern in all the file - remove if there is anything duplicate ... and keep the latest time and date format one .
and then remove the bold three columns and process the file as these columns are just for sorting - Every Bold Pattern will have 3 records inside .
If every record had these 3 columns in front of it then it is simple . But i am not understanding with all these spaces now .
Please let me know in case anyone knows if this is possible or not .
basically sort out on the unique number 00150366 and remove if there are any duplicates for this unique and choose the latest one . and send all the unique ones . Removing these fields unique number and date time ....
RudiC already told you that that script would only work if all of the times for a given field 1 were on the same date. We would hope that you would have used his suggestion as a starting point and would have figured out how to extend it to work with multiple dates.
Since your sample data was all on one day, testing for anything else is just guess work. (I'm guessing that the sample data you provided is for May 8, 2015; not August 5, 2015. If I guessed incorrectly, you'll have to modify the sort to make the month a higher order sort key than the day.)
The following produces the correct sets of lines for you, but the order of the sets of lines is different than in your sample. You didn't specify any order for the output other than that the records selected of output had to be the most recent date and time for each key value. If you want a specific order for the keys, you should have said what that order should be. Try: