wanted awk solution...
A typical problem frm me....I have a file like the following....
49998784|01|200901|41 49998784|01|200901|33 49998784|01|200901|33 49998784|01|200812|33 49998763|01|200901|33 49998763|01|200812|33 49998750|01|200812|33 49998750|01|200811|33 49998743|01|200812|33 49998743|01|200811|33 49998741|01|200902|41 49998741|01|200902|33 49998741|01|200902|33 49998741|01|200901|33 49998741|01|200901|41 49998733|01|200901|33 49998733|01|200812|33 The file has a "|" as the field separator. The first field is policy number, second one is mode,third one is due paid,fourth ono is stat. 1. if the first and third fields are same with the next record corresponding fileds, and fourth field is not same with the next record corresponding field skip these two records. 2. next, if the first and fourth fields are same, then select the record which is having a latest due(third field) and skip the other similar records and pickup next record. The out put of the above should come like this. 49998784|01|200901|33 49998763|01|200901|33 49998750|01|200812|33 49998743|01|200812|33 49998741|01|200902|33 49998733|01|200901|33 Thank you!! |
Right, and you expect us to write this script for you from scratch ? I think you should at least take a stab at it first.
For the field separator, use Code:
awk -F'|' See here for more help: http://www.grymoire.com/Unix/Awk.html |
Since you seem to want to write some sort of a programming logic which decides what content is filtered out and what's not - Ideally - I'd suggest writing an application in java that'll do the trick for you.
Let me know if you'd be interested in that .... I could cook up something that you can use! :) |
Hi sujatha,
I could solve the problem using awk but itsbit lengthy...Could you please give java solution? I work on Ubuntu8.1 and RHEL4 also. It would be great help for me(of course i am new to java, but i want to see the code) Thanks in advance. By the by I am from India and working for an Insurance Company in Hyd. |
All times are GMT -5. The time now is 08:38 PM. |