It is currently Mon, 27 Jun 2022 12:51:43 GMT



 
Author Message
 Unix - Matching data string from 2 files

Either do your own homework or drop the class.



 Wed, 10 Dec 2008 07:23:27 GMT   
 Unix - Matching data string from 2 files

You want to do a relational (as in relational database) join. Do you have
a relational database? You might be able to use the join command but
some pre-processing would be needed. Or it would be simple enough
to script in awk or perl or whatever (or a shell, given this is comp.unix.shell).

There are a couple of oddities. One is the quotes in the first file but not
in the second. Another is the word "blah" in the first which suggests this
might not be the real data.

--
John.



 Wed, 10 Dec 2008 15:18:24 GMT   
 Unix - Matching data string from 2 files
John,

That's for your help, unlike some. I figured out my code needed. For
those curious;

#Strip out quotes from file1
sed "s/\"//g" file1

awk -F ',' '
        { key = $2$4$5 }
         FNR == NR { seen[key] = $0; next }
         key in seen{ $0 = seen[key] } 1
        ' file2 file1 > newfile



 Fri, 12 Dec 2008 22:33:02 GMT   
 
   [ 3 post ] 

Similar Threads

1. Pattern matching and extracting the data which matches the pattern

2. warning: X11 auth data does not match fake data

3. warning: X11 auth data does not match fake data

4. Xauth data does not match fake data?

5. unix strings command on exp file (was Re: Editing an Export (.dmp) file)

6. dirm Unix directories file matching comparison

7. dirm Unix directories file matching comparison, Bourne shell

8. netfilter string match

9. String matching algorythm

10. Matching strings with regular expressions


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software