sed command to replace a word with new line and /


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed command to replace a word with new line and /
# 1  
Old 06-07-2012
sed command to replace a word with new line and /

Hi,


I have been trying to replace the key word

"SQL> spool off "

with

"/
show errors"

with out double quotes in all the files in a directory.
above show erros should be displayed next line

Could you please help me how to do that.

I have tried something like this but it dint work.

Quote:
sed 's:SQL> spool off:\n show errors:' test
Regards,
Pointers
# 2  
Old 06-07-2012
Code:
perl -pe 's:SQL> spool off:\n show errors:' test

# 3  
Old 06-07-2012
Thats worked for me. Thank you very much.

Is it possible to accomplish with sed commands. This is just to know how to do if it is possible to do with sed.

Regards,
Pointers

---------- Post updated at 07:15 AM ---------- Previous update was at 07:00 AM ----------

How to replace the words matching using the above commands in all the files in a directory.

Thank you very much in advance.

Regards,
Pointers
# 4  
Old 06-07-2012
like this?
Code:
# echo "SQL> spool off "|sed 's|.*|/\nshow errors|'
/
show errors

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed command to append word at end of line

hello Team, I am looking for sed command or script which will append word at end of line. for example. I want to validate particular filesystem with mount |<filesystem name> command. if nodev parameter is not there then it should add in the fstab file with receptive to the filesystem. # mount... (8 Replies)
Discussion started by: ghpradeep
8 Replies

2. Shell Programming and Scripting

sed command to replace a line in a file using line number from the output of a pipe.

Sed command to replace a line in a file using line number from the output of a pipe. Is it possible to replace a whole line piped from someother command into a file at paritcular line... here is some basic execution flow.. the line number is 412 lineNo=412 Now i have a line... (1 Reply)
Discussion started by: vivek d r
1 Replies

3. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies

4. Shell Programming and Scripting

sed command to skip the first line during find and replace operation

Hi Gurus, I did an exhaustive search for finding the script using "sed" to exclude the first line of file during find and replace. The first line in my file is the header names. Thanks for your help.. (4 Replies)
Discussion started by: ks_reddy
4 Replies

5. Shell Programming and Scripting

Replace a word using sed

Hi, I have the following line in file1 export NAME="NEW_NAME" I'm writing a shell script which reads the NEW_NAME from the user and replace in the file. I have used the following command for that read Name_replace sed -i 's/NEW_NAME/$Name_replace/' file1 but it is not... (2 Replies)
Discussion started by: Ananthdoss
2 Replies

6. Shell Programming and Scripting

SED - insert space at the beginning of line and multi replace command

hi I am trying to use SED to replace the line matching a pattern using the command sed 'pattern c\ new line ' <file1 >file 2 I got two questions 1. how do I insert a blank space at the beginning of new line? 2. how do I use this command to execute multiple command using the -e... (5 Replies)
Discussion started by: piynik
5 Replies

7. Shell Programming and Scripting

Replace word with sed

Hi there.! I'm trying to make a script that corrects wrong spelling. I want to use sed to replace wrong word with the correct one, but this must be made in a while loop that reads the wrong word from file (with read line) and the correct one from another file. I can't find a way to run sed like... (3 Replies)
Discussion started by: spiii
3 Replies

8. 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

9. Shell Programming and Scripting

Need to replace the first word of a line if it occurs again in the next line(shell)

Hi folks, have a look into the attachment, i am not familiar with unix, can you please help me in this regard. thanks in advance, :) regards, Geeko (4 Replies)
Discussion started by: geeko
4 Replies

10. UNIX for Dummies Questions & Answers

How to search and replace a particular line in file with sed command

Hello, I have a file and in that, I want to search for a aprticular word and then replace another word in the same line with something else. Example: In file abc.txt, there is a line <host oa_var="s_hostname">test</host> I want to search with s_hostname text and then replace test with... (2 Replies)
Discussion started by: sshah1001
2 Replies
Login or Register to Ask a Question