![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need to find a multiple line block and replace with a multiple line block | Randem | Shell Programming and Scripting | 8 | 09-29-2009 12:24 PM |
| Delete block of text in one file based on list in another file | Festus Hagen | Shell Programming and Scripting | 3 | 09-04-2009 12:07 AM |
| how to append a block of statements after another block in the file | aoussenko | Shell Programming and Scripting | 5 | 04-13-2009 10:34 AM |
| help to get the block from a file | palsevlohit_123 | UNIX for Advanced & Expert Users | 6 | 10-09-2008 09:57 AM |
| extract block in file | sskb | UNIX for Dummies Questions & Answers | 5 | 10-25-2001 11:29 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|