Thanks PHV and feherke.
PHV: Sorry, maybe the example was not clear enough. The no of tables I have is about 70, and to type in every char in lower and upper for ever table would be a pain.
feherke: Yes that does the trick. But for a certain entry in replace_tab_names.txt the substitution...
...s/TAB_NAME_C/TAB_NAME_NEW_C/ig
}
Then I have shell script (sed_replace.sh) which looks like
for filename in `ls -1 V_*.sql `
do
sed -f replace_tab_names.txt $filename > $filename.A2
done
Ofcourse it says
sed: command garbled:
and that is because of the "i" for case insensitive...
Hi,
Is there a way to strip off the last few characters of a string. ( In my example, I need to stroip the last 4 characters)
So the example input strings are
2276680000EUR201020971
2338810000EUR201021861
And the output I need is
2276680000EUR20102
2338810000EUR20102
I couldnt see any...
Hi
I have a file which has things like
CREATE TABLE ....
...
;
;
CREATE TABLE ...
;
CREATE TABLE ...
; ;
CREATE TABLE ...
/
CREATE TABLE ...
/
;
I need to find out the occurances of semi colon followed by nothing then a semicolon.
Is there a way to do it in some kind of a awk...
Hey PHV. That works. Thanks.
Sorry feherke. It works on the small set of test script posted above, but not on the original huge SQL file.
I had constructed the test file by copying the text I need to look for(CREATE OR REPLACE VIEW), from the huge SQL file. So it is not the case mismatch. It...
Thanks for the response feherke.
But if I dont reset the var after every print then I will get back all the occurances. Whereas I am only after 1st, 3rd, etc. So I am saying
Is the var !set and is the statement CREATE OR REPLACE
if yes print the line and set the var.
So for the next...
Hi ,
I have a SQL file with a set of CREATE OR REPALCE statements. There are always two sets for every object created. I need the first occurance of each of these statements...
Like for example...
#my_orig_file.sql
CREATE OR REPLACE view test1
as select sysdate from dual;
CREATE OR REPLACE...
Hi,
I need to do something like
for i `ls -1 *.sql `
do
for k in `grep "MY TEXT" $j `
do
..
...
..
done
done
And one of the sql files may contain lines like
MY TEXT ABC
fkjgnhdfg
MY TEXT PQR
dfkljgn
MY TEXT XYZ
So a grep would return three lines and I want to work on the three...
...K-shell script and I am one third there, i.e. out of the three stmts I can now convert the first one. The script is as below....
for i in `ls -1 *.sql`
do
echo $i
old_text=`grep "ADD CONSTRAINT" $i | grep "_UK" | grep "MNDCD" `
constraint_name=`echo $old_text | awk ' {print $3 } ' `...
I have hit a snag. I cannot look for TEST_OLD_FK
but need to look for
DROP CONSTRAINT *_OLD_FK, where * can be anything. I mean it could be AAA_OLD_FK or BBBBBB_OLD_FK or CC_OLD_FK. I tried using a * or even a regex like [A-Z]* but that didnt work. What am I doing wrong.
That does the trick, though I have used the second code with the gsub.
A question on the first code: I thougth NF was for number of fields in a record, but you seem to be matching a text. I guess you can use it only if the text is the last word ( as you said).
Many Thanks.
Thanks Feherke, but I get the error on both the pieces of code.
awk: syntax error near line 1
awk: bailing out near line 1
Is there a way of debugging...When I got the errors I tried to use nawk instead of awk. But no luck there.
Hi ,
I have a huge file with a lot of oracle statements. In there is there a way to do the following
When I come across the text "_OLD_FK" like below lines
ALTER TABLE TEST$AB DROP CONSTRAINT TEST_OLD_FK
/
I need to add another set of lines with the _OLD_FK replaced with _NEW_FK
so the...
...doing.
I understand the general principle which is to look for the text insert and to make it case insensitive you have added the tolower. Print /* and then keep looking for the next commit, increment 2 lines and then print */
But would be helpful if you could explain the number logic you...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.