match 2 files by values


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting match 2 files by values
# 1  
Old 01-27-2012
match 2 files by values

Hello ALL,

Hope all fine for you.
I have the following task but no idea about how to do.

I have 2 files (ascii)
one of them is a list of bib records, looks like this:

Code:
 
=LDR  01228nam  2200301 b 4500
=001  00000000000001
=005  20090429:10082000
=008  060403\2004\\\\\\\\\\\\\\\\\\\\\\\\baq
=008  120114s9999\\\\xx\\\\\\\\\\\\000\0\und\d
=019  \\$aM-34416-2004
=020  \\$a84-667-3834-7
=027  \\$a11100
=024  \\\$a9
=100  1\$aFerrero, Luis
=245  10$aMatematika$b :2:  Irakasleentzako materiala$c / Luis Ferrero, María del Carmen Jiménez, María Gregoria Martín
=260  \\$aMadrid$b : Anaya-Haritza$c, 2004
=300  \\$a4 bolumen dituen karpeta  (159, 31, 39, 95 or.)$c ; 32 x 26 cm
=440  \0$aApain eta dotore
=500  \\$a2004.10.19
=505  0\$a1. bolumena: Proposamen didaktikoa$a -- 2. bolumena: Programazioa$a -- 3. bolumena: Ebaluazioa$a -- 4. bolumena: Aniztasunaren tratamendua
=521  0\$a2.maila
=650  \4$aLMH - Matematika
=700  1\$aJimenez, Maria del Carmen
=700  1\$aMartín, María Gregoria
=856  \\$u http://www.anaya.es$z Argitaletxearen web-orria
=856  \\$u http://www.hezkuntza.ejgv.euskadi.ne...66738347.pdf$z Aurkibidea
=952  \\$p1000001$8LH$d05/04/06$aEK$bEK$oI LH2 MAT 1 04$eANA$s05/04/06
=998  \\9
=LDR  01239nam  2200373 b 4500
=001  00000000000003
=005  20081212:09412200
=008  060403m20032004esp\\\\e\\\\\\001\1\baq\c
=008  120114s9999\\\\xx\\\\\\\\\\\\000\0\und\d
=019  \\$aBI 2674-2003 (1. libk.)
=019  \\$aBI 2934-2004 (2. libk.)
=020  \\$a84-88303-11-4 (1. libk.)
=020  \\$a84-88303-01-7 (2. libk.)
=020  \\$a84-88303-12-2 (o. o.)
=024  \\\$a11
=041  0\$abaq$h lat
=080  \\$a1 Tomas Akinokoa, Santua
=100  0\$aTomas Aquinokoa$c, Santua$d (1225?-1274)
=245  10$aTomas Akinokoaren lan hautatuak$c / Tomas Akinokoa ; euskaratzailea: Julen Kalzada ; berrikuslea: Lorea Arrieta Zubillaga ; hitzaurregilea: Ralph McInerny
=250  \\$a1. argit
=260  \\$aBilbo$b : Klasikoak$c, 2003-2004
=300  \\$a2 libk.$c ; 24 cm
=440  \0$aKlasikoak 1991
=500  \\$a2003.07.24
=500  \\$a2004.12.19
=650  \4$a Etika
=650  \4$aPatristika
=650  \4$aFilosofia
=700  1\$aKaltzada, Julen
=700  1\$aArrieta Zubillaga, Lorea
=700  1\$aMcInerny, Ralph
=856  \\$u http://www.klasikoak.com/$z Argitaletxearen web-orria
=952  \\$p1000000$8MON$d03/04/06$aEK$bEK$o1 AKI tom$eKLA$s03/04/06
=998  \\11

As you see, each record starts with =LDR and ends with a blank line
So, in this file you'll see the field =650 for example: =650 \4$aFilosofia
ok
Then in the second file looks like:

...
T505
«0 »«a»1. bolumena: Proposamen didaktikoa«a» -- 2. bolumena: Programazioa
«a» -- 3. bolumena: Ebaluazioa«a» -- 4. bolumena: Aniztasunaren tratamendua
T521
«0 »«a»2.maila
T650
« 4»«a»Filosofia«ZZ0007003»
T700
«1 »«a»Jimenez, Maria del Carmen«ZZ0001284»
...

it's a relation list, in this file you'll find the same field (650) with a text value and a numeric value.
This one:
T650
« 4»«a»Filosofia«ZZ0007003»

so the objective is to add the numeric value into the first file (a merge)
Some one konws how to do this??

Thanks a lot
# 2  
Old 01-27-2012
You post so many topics, but never thanks to anyone?

Seem some similar topics already posted by you, so many codes you need understand from them first.

Show us what you have done, not just waiting for others' free help.
# 3  
Old 01-27-2012
Hello
I always thanks all the people responding, I'l database admin so I can help with any question in relation with this. Is there any database zone in the forum? I'll be pleased to give all the help I can.
Cheers

---------- Post updated at 07:23 AM ---------- Previous update was at 07:16 AM ----------

Hooo yes I see now,
there is a Thanks buton, I never see it before !!
I'm very confused.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Data match 2 files based on first 2 columns matching only and join if match

Hi, i have 2 files , the data i need to match is in masterfile and i need to pull out column 3 from master if column 1 and 2 match and output entire row to new file I have tried with join and awk and i keep getting blank outputs or same file is there an easier way than what i am... (4 Replies)
Discussion started by: axis88
4 Replies

2. Shell Programming and Scripting

Match value in two files and replace values in selected columns

The purpose is to check if values for column 3 and 4 in file1 match with column 1 in file2. If any value match do: 1) Replace values in file2 for column 2 and 3 using the information of file1 columns 5 and 6 2) Replace string ($1,1,5) and string ($1,6,5) in file2 with values of columns 7... (8 Replies)
Discussion started by: jiam912
8 Replies

3. Shell Programming and Scripting

awk to match field between two files and use conditions on match

I am trying to look for $2 of file1 (skipping the header) in $2 of file2 (skipping the header) and if they match and the value in $10 is > 30 and $11 is > 49, then print the line from file1 to a output file. If no match is foung the line is not printed. Both the input and output are tab-delimited.... (3 Replies)
Discussion started by: cmccabe
3 Replies

4. Shell Programming and Scripting

Match values in awk

Having trouble modifying the below awk to match $1 of sample.txt to $1 of data.txt and if there is a match, then $2 of data.txt is copied to $7 of sample.txt. Thank you :). awk 'NR==FNR{A=$1; next} A {$1=$1 " " A}1' data.txt sample.txt > output.txt Desired Output: Data... (3 Replies)
Discussion started by: cmccabe
3 Replies

5. Shell Programming and Scripting

Using awk to match strings and outputing their corresponding values

Hi I will appreciate it if you can help me out. I have a file that contains this data System Load: 3244 card: 1903 CPU: 6% card: 1904 CPU: 6% card: 1905 CPU: 28% card: 1906 CPU: 28% card: 1907 CPU: 36% card: 1908 CPU: 37% I need to manipulate and output this as system_load:3244... (2 Replies)
Discussion started by: kaf3773
2 Replies

6. UNIX for Dummies Questions & Answers

Comparing two test files and printing out the values that do not match

Hi, I have two text files with matching first columns. Some of the values in the second column do not match. I want to write a script to print out the rows (only the first column) where the values in the second column do not match. Example: Input 1 A 1 B 2 C 3 D 4 Input 2 A 2 B 2... (6 Replies)
Discussion started by: evelibertine
6 Replies

7. UNIX for Dummies Questions & Answers

Match values/IDs from column and text files

Hello, I am trying to modify 2 files, to yield results in a 3rd file. File-1 is a 8-columned file, separted with tab. 1234:1 xyz1234 blah blah blah blah blah blah 1234:1 xyz1233 blah blah blah blah blah blah 1234:1 abc1234 blah blah blah blah blah blah n/a RRR0000 blah blah blah... (1 Reply)
Discussion started by: ad23
1 Replies

8. UNIX for Dummies Questions & Answers

Comparing two text files by a column and printing values that do not match

I have two text files where the first three columns are exactly the same. I want to compare the fourth column of the text files and if the values are different, print that row into a new output file. How do I go about doing that? File 1: 100 rs3794811 0.01 0.3434 100 rs8066551 0.01... (8 Replies)
Discussion started by: evelibertine
8 Replies

9. Shell Programming and Scripting

Get values from different columns from file2 when match values of file1

Hi everyone, I have file1 and file2 comma separated both. file1 is: Header1,Header2,Header3,Header4,Header5,Header6,Header7,Header8,Header9,Header10 Code7,,,,,,,,, Code5,,,,,,,,, Code3,,,,,,,,, Code9,,,,,,,,, Code2,,,,,,,,,file2... (17 Replies)
Discussion started by: cgkmal
17 Replies

10. UNIX for Dummies Questions & Answers

Match values from 2 files and append certain fields

Hi, I need help on appending certain field in my file1.txt based on matched patterns in file2.txt using awk or sed. The blue color need to match with one of the data in field $2 in file2.txt. If match, BEGIN and FINISHED value in red will have a new value from field $3 and $4 accordingly. ... (1 Reply)
Discussion started by: redse171
1 Replies
Login or Register to Ask a Question