How to replace a text containing new lines using sed or any other method?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to replace a text containing new lines using sed or any other method?
# 1  
Old 05-31-2012
How to replace a text containing new lines using sed or any other method?

Hi,
i want to replace
"Hi How
are You when
did you go to
delhi"

to
"Hi How
are you when
did you come from
delhi"

in a file.

Any idea how to do it?
# 2  
Old 05-31-2012
Is this a work related question, smells like home work to me...
# 3  
Old 05-31-2012
Obviously its work related question.
I just simplified it so that it'll be easy to understand and try i take the clue and apply it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[sed] Replace one line with two lines

Literally cannot get this one, guys. Single line replacement is simple, but I am not understanding the correct syntax for including a new line feed into the substitution part. Here's what I got. (Cannot use perl) #!/bin/sh set -f #Start Perms export HOME=/home/test_user # End Perms... (6 Replies)
Discussion started by: Parallax
6 Replies

2. Shell Programming and Scripting

Replace multiple lines through sed

Hi All, I have a input file as sample below <this is not starting of file> record line1 line2 line3 end line4 line5 record line6 line7 line8 my requirement is this, i want to select a pattern between first record and end, whatever is written between first record and end. and... (0 Replies)
Discussion started by: adgangwar
0 Replies

3. Shell Programming and Scripting

sed show lines text between 2 blank lines

I have a file like blah blah blah blah this is the text I need, which might be between 1-4 lines, but always has a blank line above and below it, and is at the end of the text file the code tags don't show the trailing blank line. I started by deleting the last blank line with: ... (2 Replies)
Discussion started by: unclecameron
2 Replies

4. Shell Programming and Scripting

replace text with SED

Hi, I hope someone can help me out with the following: I have a file with the following lines in it: something /path/dir/my_-_file.01.ext sometext sometext somethingelse /path/dir/my_-_file.02.ext sometext something /path/dir/my_-_file.03.ext sometext some other text And i want to... (3 Replies)
Discussion started by: thyssimonis
3 Replies

5. Shell Programming and Scripting

sed to replace two lines with one

I want to use sed to check if a short line is contained in the line after it, and if it is, to delete the short one. In other words, the input is... This is a This is a line ... and I want it to give me... This is a line Here's what I've tried so far: s/\(^.*\)\n\(\1.*$\)/\2/ Also,... (7 Replies)
Discussion started by: estebandido
7 Replies

6. Shell Programming and Scripting

Help with sed - replace text

Hi, I need to replace text in a file. Can someone help me write the proper sed command for this? My text file contains about a 100 lines of content. I want to replace the line containing new_name = "#{options}-#{ENV}" by, the following - new_name = "#{options}-#{ENV}-#{rand(999)}" ... (1 Reply)
Discussion started by: ankush2kn
1 Replies

7. UNIX for Advanced & Expert Users

Replace the text between two lines with different text

I have a file which contains the following data. Parameters "CParameters" BEGIN DSSUBRECORD Name "TgtDB" Prompt "TgtDB" Default "edwdev" ParamType "0" ParamLength "0" ParamScale "0" END DSSUBRECORD MetaBag... (6 Replies)
Discussion started by: ukatru
6 Replies

8. Shell Programming and Scripting

SED - Search and replace lines containing...

Hi, I need a sed line that will find all lines that contain "<int key="NSWindowStyleMask">" and then replace the entire line (not just that one string) with "<int key="NSWindowStyleMask">8223</int>". It doesn't necessarily have to use sed as long as it gets the job done :) Thanks (9 Replies)
Discussion started by: pcwiz
9 Replies

9. UNIX for Dummies Questions & Answers

how to replace one line in text with several lines

Hi, I need to replace a specific line in a text (eg the line contains the word MYSERVER) with a number of lines (let's say 4) in which the word MYSERVER will be replaced with server1 in the first line server2 in the second line server3 in the 3rd line server4 in the 4th line The original... (1 Reply)
Discussion started by: FunnyCats
1 Replies

10. Shell Programming and Scripting

Replace Text with sed

Hi , I´m working on Solaris 9 SPARC and I´m writing a Script to mírror two disks.. I need to replace some text in a file ( /etc/vfstab ) . For example: /dev/dsk/c0t0d0s0 ==> /dev/md/dsk/d0 I just want to change the "/dev/dsk/" to "/dev/md/dsk/. Thanks for your repsonse (5 Replies)
Discussion started by: networkfre@k
5 Replies
Login or Register to Ask a Question