sed command to overwrite


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed command to overwrite
# 1  
Old 06-02-2010
sed command to overwrite

Hi,

i have a file ver.sql with the following contents , Here i need to put a in the next line of END statment .
So iam doing the following

Code:
D:\>type ver.sql
begin
ctxsys.driimp.set_value('STOP_WORD','yours');
ctxsys.driimp.set_object('STORAGE','BASIC_STORAGE',2);
ctxsys.driimp.set_value('R_TABLE_CLAUSE','lob (data) store as (cache)');
ctxsys.driimp.set_value('I_INDEX_CLAUSE','compress 2');
commit;
COMMIT;  END;

D:\>sed "s@END;@ END;\n/@g" ver.sql >>ver.log

D:\>type ver.log
begin
ctxsys.driimp.set_value('STOP_WORD','yours');
ctxsys.driimp.set_object('STORAGE','BASIC_STORAGE',2);
ctxsys.driimp.set_value('R_TABLE_CLAUSE','lob (data) store as (cache)');
ctxsys.driimp.set_value('I_INDEX_CLAUSE','compress 2');
commit;
COMMIT;   END;
/

It works fine now , Here in my source file (ver.sql ) , if i already get a slash (/) after the end statment, then it need to overwrite it. But in my case it is appending in the next line ..

Code:
D:\>type ver.sql
begin
ctxsys.driimp.set_value('STOP_WORD','yours');
ctxsys.driimp.set_object('STORAGE','BASIC_STORAGE',2);
ctxsys.driimp.set_value('R_TABLE_CLAUSE','lob (data) store as (cache)');
ctxsys.driimp.set_value('I_INDEX_CLAUSE','compress 2');
commit;
COMMIT;  END;
/

D:\>sed "s@END;@ END;\n/@g" ver.sql >>ver.log

D:\>type ver.log
begin
ctxsys.driimp.set_value('STOP_WORD','yours');
ctxsys.driimp.set_object('STORAGE','BASIC_STORAGE',2);
ctxsys.driimp.set_value('R_TABLE_CLAUSE','lob (data) store as (cache)');
ctxsys.driimp.set_value('I_INDEX_CLAUSE','compress 2');
commit;
COMMIT;   END;
/
/


how to overwrite this?

---------- Post updated at 06:12 AM ---------- Previous update was at 05:40 AM ----------

Any updates please

Last edited by pludi; 06-02-2010 at 07:49 AM.. Reason: code tags, please...
# 2  
Old 06-02-2010
Try:
Code:
sed "/END;/{N;s@END;\(\n/\)\{,1\}@ END;\n/@g}" ver.sql >>ver.log

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. SCO

Command line overwrite

is there a way to overwrite what I have typed in rather than having to hit enter and re enter the command? SCO UNIX 3.2.4.2 (14 Replies)
Discussion started by: steveo314
14 Replies

2. Shell Programming and Scripting

Overwrite bash system command

Hello, The problem I met is the conflict between the default command /usr/bin/sometools, which is an very old version at system setup, and an updated one I have installed in $HOME/download-software/sometools How do I tell a third program to use the customized sometools instead of the default... (6 Replies)
Discussion started by: yifangt
6 Replies

3. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies

4. Shell Programming and Scripting

Better to Delete or Overwrite

Hello All, I had just a question about my Bash Script I'm currently writing. The script I have writes some text to a output file. After I write to the output file I send the file to another server to do some stuff with it. After the file sends in the script, I don't need the output/txt... (4 Replies)
Discussion started by: mrm5102
4 Replies

5. Shell Programming and Scripting

Field overwrite using sed or awk

Is there a way to overwrite a specific field (i.e. line 2 field 3 without getting its contents). For example I would like to simply have a compatible Solaris 10 command line that replaces line 2 field 3 with contents of a variable. I would like to use SED or AWK if possible, but other suggestions... (1 Reply)
Discussion started by: thibodc
1 Replies

6. UNIX for Dummies Questions & Answers

overwrite problem

my script is: awk '...mycode...' file1.txt > file2.txt and i want to overwrite file2.txt eachtime I run this script. but it says:File exists! :( I have tried awk '...mycode...' file1.txt >| file2.txt but it again says:Missing name for redirect! :confused::confused: what is this? (2 Replies)
Discussion started by: gc_sw
2 Replies

7. Shell Programming and Scripting

Loop with sed command to replace line with sed command in it

Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line. ... (1 Reply)
Discussion started by: cbo0485
1 Replies

8. UNIX for Dummies Questions & Answers

overwrite problem

Hi im using the following to copy a file to a directory, the user being prompted to overwrite if the file already exists in that directory, cp -i myfile /home/brief/bin2 but this reveals the path of the directory when being prompted to overwrite (below) cp: overwrite... (2 Replies)
Discussion started by: ali999
2 Replies

9. UNIX for Dummies Questions & Answers

Overwrite

if i want to pipe output to a file, say, cat abc.dat > abc.txt, how do i make it replace the existing file? (9 Replies)
Discussion started by: Duckman
9 Replies
Login or Register to Ask a Question