finding a block in a file and replace with another file block.

(1) Yes but how is this block different from the other 24? You will need this information in order to identify and replace this block correctly (out of the 25).

Ans: The 1st line and last line of this block are unique from other block.
The 1st line is �rem Subset Rows (&&tempName.*) and
The last line is �WHERE testvalue is not null�. Through this way I can identify this block.

(2) Are all the blocks identical? If so, which block do you want replaced? The 1st, 2nd, 25th? Or all?

Ans: Not all block are identical only few of them are identical. The block which I want to replace is not present in this file (xyz_abc.sql). I want to find this identical block from xyz_abc.sql and then replace the block which is present in another file called repl_file.sql.

The xyz_abc.sql file contains 25 blocks. In xyz_abc.sql file I need to identify the following 5 lines block.

rem Subset Rows (&&tempName.)
CREATE VIEW &&tempName.
AS
SELECT *
FROM &&tempName.*
WHERE testvalue is not null.

And then replace with following block which is present in repl_file.sql. This repl_file.sql contains only one block.

rem Subset Rows (&&tempName.)
CREATE VIEW &&tempName.
AS
SELECT STUDYID STUDYID, DOMAIN DOMAIN, USUBJID USUBJID, ggg(y) ABSEQ,
ABGRPID ABGRPID, ABREFID ABREFID, ABSPID ABSPID, testvalue
testvalue, ABTEST ABTEST, ABCAT ABCAT, ABSCAT ABSCAT, ABPOS
ABPOS, ABOARES ABOARES, ABORRESU ABORRESU, ABNRIND ABNRIND,
ABSERESC ABSERESC, ABSTEESN ABSTEESN, ABSTRESU ABSTRESU,
ABSTAT ABSTAT, ABREBSND ABREBSND, ABXFN ABXFN, ABNAM ABNAM,
ABLOINC ABLOINC, ABMETHOD ABMETHOD, ABBLFL ABBLFL, ABDRVFL
ABDRVFL, ABEVAL ABEVAL, VISIT VISIT, VISITNUM VISITNUM,
VISITDY VISITDY, ABDTC ABDTC, ABDY ABDY, ABTPTNUM ABTPTNUM,
ABTPT ABTPT, ABELTM ABELTM, ABTPTFEF ABTPTFEF, X1 X1, X2 X2,
X3 X3, X4 X4, X5 X5, X6 X6, X7 X7, X8 X8, X9 X9, X10 X10, X11
X11, X12 X12, X13 X13, X14 X14, X15 X15, X16 X16, X17 X17, X18
X18, X19 X19, X20 X20, X21 X21, X22 X22, X23 X23, X24 X24, X25
X25, X26 X26, X27 X27, X28 X28, X29 X29, X30 X30
FROM &&tempName.*
WHERE testvalue is not null

The 1st line and last of this block is unique. thru this way can identify.

Not all the blocks are identical only few of them is identical. The block which i want replace is not present in xyz_abc.sql.

can we do this way.

my target file should be removed the identical block from xyz_abc.sql file and replace with repl_file.sql file block.

Please suggest.

Thanks in advance

---------- Post updated at 11:37 PM ---------- Previous update was at 11:59 AM ----------

Please suggest some code

Thanks in Advance

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.