![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| filtering the logs | prvnrk | Shell Programming and Scripting | 5 | 04-08-2008 06:57 PM |
| awk and sed filtering | invinzin21 | Shell Programming and Scripting | 2 | 01-10-2008 11:56 PM |
| awk filtering ? | varungupta | UNIX for Advanced & Expert Users | 4 | 09-16-2007 11:55 PM |
| Filtering Data | Raynon | Shell Programming and Scripting | 7 | 09-05-2007 03:38 PM |
| Filtering out data ... | videsh77 | UNIX for Dummies Questions & Answers | 1 | 12-29-2004 12:59 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
file1 contain: (this just a small sample of data it may have thousand of lines)
1 aaa 1/01/1975 delhi 2 bbb 2/03/1977 mumbai 3 ccc 1/01/1975 mumbai 4 ddd 2/03/1977 chennai 5 aaa 1/01/1975 kolkatta 6 bbb 2/03/1977 bangalore program: nawk '{ idx= $2 SUBSEP $3 arr[idx] = (idx in arr) ? arr[idx] ORS $0 : $0 arrCnt[idx]++ } END { for (i in arr) if (arrCnt[i] > 1) print arr[i] }' file1 Result: 2 bbb 2/03/1977 mumbai 6 bbb 2/03/1977 bangalore 1 aaa 1/01/1975 delhi 5 aaa 1/01/1975 kolkatta Questions: How the code should be if I need the data result to be like this : 1 aaa 1/01/1975 delhi 3 ccc 1/01/1975 mumbai 2 bbb 2/03/1977 mumbai 4 ddd 2/03/1977 chennai Please help! Thank you friends! |
| Forum Sponsor | ||
|
|
|
|||
|
More Info
It is good that you have supplied 'in' file format and wanted/desired 'out' format but it will help if you can tell us what the actual need is.
What is the algorithm/method you want to apply to the input to generate the output - it is not too clear from your examples. I am guessing you want to get entries from aaa until aaa is repeated. Is this the case? |
|
|||
|
The requests are:
the program will go line #1; it will compare this line #1 to every line in the file; and if column #2 is not match AND column #3 is match to the next lines, then print all the lines those meet the condition. The program will go to line #2 and repeat the process til the end of the file. I am not sure this is clear enough. Please let me know. |
|||
| Google The UNIX and Linux Forums |