![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to grep / zgrep to output ONLY the matching filename and line number? | vvaidyan | UNIX for Dummies Questions & Answers | 3 | 03-12-2008 05:33 PM |
| how to delete line with matching text and line immediately after | orahi001 | UNIX for Dummies Questions & Answers | 6 | 01-15-2008 12:34 AM |
| perl pattern matching vs. grep | junkmail426 | Shell Programming and Scripting | 0 | 09-28-2005 10:40 AM |
| Grep all files matching partial filename | mharley | Shell Programming and Scripting | 3 | 06-08-2005 02:17 PM |
| matching multiple times in same line | oldtrash | Shell Programming and Scripting | 2 | 04-28-2004 05:57 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Below is the scenario. Help is appreciated.
File1: ( 500,000 lines ) : Three fields comma delimited : Not sorted 1234FAA,435612,88975 1224FAB,12345,212356 File2: ( 4,000,000 lines ) : Six fields comma delimited (Last 3 field should match the 3 fields of File1) : Not Sorted : 0123456abcd,12345,abcdef,1234FAA,435612,88975 0123456wxyz,11234,lmnopq,1224FAB,12345,212356 I need to grab all the six fields for file2 when there is a match of first 3 fields of file1 and last 3 fields of file2. I wrote a small script but seems like it might take days to complete :-) 1 #!/bin/ksh 2 3 while read record 4 do 5 cat file2 | grep "$record" >> final.list 6 done < file1 Can someone help me with a faster solution? Thanks in advance. |
|
||||
|
vgersh99,
The following ran for about 45-50 minutes and completed, but the output file was empty. Could you please give me more insight on what is happening below? Thanks gawk -F',' -f hem.awk file1 file2 > final.list hem.awk: FNR==NR { f1[$0]; next} ( $(NF-2) FS $(NF-1) FS $(NF) ) in file1 ShellLife, The egrep command ran over an hour and killed it. I kicked it off again to see how long it runs. Thanks |
![]() |
| Bookmarks |
| Tags |
| linux |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|