Replacing a paragraph between pattern , with the content 4m another file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replacing a paragraph between pattern , with the content 4m another file
# 1  
Old 12-07-2006
Question Replacing a paragraph between pattern , with the content 4m another file

hi,
i wanted to put the output of file f1 into the pattern space of file f2

f1:
wjwjwjwjwjwjwj //these line go in file f2
jwjwjwjwjwjjwjw
wjwjwjwjjwjwjwj

f2:
Pattern_start
__________ //these are the line to be replaced
__________
Pattern_end

i m using sed as:
sed 's/Pattern_start/,/Pattern_end/`cat f1`/g' file2

it says
sed: Function s/Pattern_start/,/Pattern_end/wjwjwjwjwjwjw cannot be parsed.


pls help Smilie Smilie Smilie Smilie

Last edited by go4desperado; 12-07-2006 at 07:55 AM.. Reason: typo
# 2  
Old 12-07-2006
Code:
sed -n '/Pattern_start/,/Pattern_end/{/^Pattern/! d;}" file2 | sed "/Pattern_start/r f1"

# 3  
Old 12-07-2006
Quote:
Originally Posted by anbu23
Code:
sed -n '/Pattern_start/,/Pattern_end/{/^Pattern/! d;}" file2 | sed "/Pattern_start/r f1"

wat is Pattern in this ...
# 4  
Old 12-07-2006
Code:
sed -n '/Pattern_start/,/Pattern_end/{/^Pattern/! d;}" file2 | sed "/Pattern_start/r f1"

/^Pattern/ Are you asking this?
Used this to avoid deleting the Pattern_start and Pattern_end lines.
If the lines between Pattern_start and Pattern_end contain only hyphens then you can use this

Code:
sed -n '/Pattern_start/,/Pattern_end/{/^---*/d;}" file2 | sed "/Pattern_start/r f1"

# 5  
Old 12-07-2006
Quote:
Originally Posted by anbu23
Code:
sed -n '/Pattern_start/,/Pattern_end/{/^Pattern/! d;}" file2 | sed "/Pattern_start/r f1"

/^Pattern/ Are you asking this?
Used this to avoid deleting the Pattern_start and Pattern_end lines.
If the lines between Pattern_start and Pattern_end contain only hyphens then you can use this

Code:
sed -n '/Pattern_start/,/Pattern_end/{/^---*/d;}" file2 | sed "/Pattern_start/r f1"

thanx dude...

u r FAB
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert content of file before the first occurrence of a line starts with a pattern in another file

Hi all, I'm new to scripting.. facing some problems while inserting content of a file into another file... I want to insert content of a file (file2) into file1, before first occurrence of "line starts with pattern" in file1 file1 ====== working on linux its unix world working on... (14 Replies)
Discussion started by: Jagadeesh Kumar
14 Replies

2. Shell Programming and Scripting

Replacing partial content of a file.

Hi All, Please help me in the below issue.I had a file called env.prop.In that i need to change service.url.If i select chocie 2. it should come as https://dev2.ecif.info53.com:30102/soap/default 30102 port is not fixed .It varies when the file is updated.So i want to keep orginal port in... (3 Replies)
Discussion started by: bhas85
3 Replies

3. Shell Programming and Scripting

Finding the pattern and replacing the pattern inside the file

i have little challenge, help me out.i have a file where i have a value declared and and i have to replace the value when called. for example i have the value for abc and ccc. now i have to substitute the value of value abc and ccc in the place of them. Input File: go to &abc=ddd; if... (16 Replies)
Discussion started by: saaisiva
16 Replies

4. Shell Programming and Scripting

Pattern Matching & replacing of content in file1 with file2

I have file 1 & file 2 with content mentioned below. I want to get the output as shown in file3. Requirement: check the content of column 1 & column 2, if value of column 1 in file1 matches with first column of file2 then remaining columns(2&3) of file2 should get replaced, also if value of... (4 Replies)
Discussion started by: siramitsharma
4 Replies

5. Shell Programming and Scripting

Inserting file content into a searched pattern

Hi, i have to insert the content of source.txt into the searched pattern of the file second.txt. $cat source.txt One Two Three . . $cat second.txt This is second file pattern match start here pattern match end here end of the file so the result will be like this (4 Replies)
Discussion started by: posix
4 Replies

6. Shell Programming and Scripting

sed command for copying the contents of other file replacing it another file on specifc pattern

We have 2 file XML files - FILE1.XML and FILE2.xml - we need copy the contents of FILE1.XML and replace in FILE2.xml pattern "<assignedAttributeList></assignedAttributeList>" FILE1.XML 1. <itemList> 2. <item type="Manufactured"> 3. <resourceCode>431048</resourceCode> 4. ... (0 Replies)
Discussion started by: balrajg
0 Replies

7. UNIX for Dummies Questions & Answers

Output text from 1st paragraph in file w/ a specific string through last paragraph of file w/ string

Hi, I'm trying to output all text from the first paragraph in a file that contains a specific string through the last paragraph in that file that contains that string. Previously, I was outputting just each paragraph with that search string with: cat in_file | nawk '{RS=""; FS="\n";... (2 Replies)
Discussion started by: carpenn
2 Replies

8. Shell Programming and Scripting

Pattern in a paragraph

Hi, I have read similar questions and I was not able to get a solution, so please help :) I have two files: 1-Pattern file contains list of patterns pattern1 pattern2 pattern3 pattern4 .... pattern# 2-input file in the format >hdhfshsdfjhpattern1xmbxmbxnmv... (4 Replies)
Discussion started by: tbakheet
4 Replies

9. Shell Programming and Scripting

replacing a pattern in a file

Hi guys, i have a pattern that i am searching in a file and i want to extract some of this pattern ... module TS1N65ULPA96X32M4 ( .... i want to extract only TS1N65ULPA96X32M4 part and i do the following sed 's/module \(x*\).*/\1/' name_of_file but this is not quite right. could... (6 Replies)
Discussion started by: ROOZ
6 Replies

10. Shell Programming and Scripting

help with finding & replacing pattern in a file

Hi everyone. Could u be so kind and help me with on "simple" shell script? 1. i need to search a file line by line for a pattern. example of a lines in that file 2947 domain = feD,id = 00 0A 02 48 17 1E 1D 39 DE 00 0E 00,Name Values:snNo = f10 Add AttFlag = 0 2. i need to find... (0 Replies)
Discussion started by: dusoo
0 Replies
Login or Register to Ask a Question