Page 1 of 1

Find then use found to search second file for replacement

Posted: Thu Sep 21, 2006 2:09 pm
by Colin
Hi,
I am a new usr and have a particularly dfficult proble,

I have two files which have a common field between them. I wish to search the first file for a term then use that term to search the second file for the replacement line.

example text:

First file:

58code_86D
58code_88C
etc

Second file:
POWER_UP,CODE,086D,2941
STRT0,CODE,088C,2960

Thus in the first line of the first file the text 58code_86D would be found.
The characters following "_" would be used to search the second file.
This would find the following "POWER_UP,CODE,086D,2941" .
This text would replace the text found in the first file.
Regexes would find both terms but I cannot work out whether the first found text can be passed to a variable that can be used to searc a second file.

Can this be done?

Colin Close

Posted: Sun Sep 24, 2006 11:47 am
by Abacre
How many files do you have in total? Just two files file1 and file2 or
do you have hundreds of similar files?

In file1 do you need to search only once 58code_86D
or you have to iterate between all occurrences 58code_86D, then find
88C in file1 and replace 88C in file2 and so on.

I think that the best way to solve this task: you send to support@abacre.com - file1,
file2 before replace, file2 after replace.