The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need Replacement for sed dbsurf Shell Programming and Scripting 0 01-25-2008 02:47 PM
Replacement of Delimiter panknil Shell Programming and Scripting 3 05-14-2007 04:35 AM
Replacement using sed handak9 UNIX for Dummies Questions & Answers 5 07-13-2004 08:28 AM
cpu replacement. help IMPTRUE UNIX for Dummies Questions & Answers 3 07-25-2003 05:40 AM
global replacement Babu UNIX for Dummies Questions & Answers 2 07-04-2001 06:02 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-21-2007
Registered User
 

Join Date: May 2007
Posts: 4
Stumble this Post!
Smile Regarding Replacement

I have two files:

file1:
somedata
<html>
<head>
This is sample statement
......
......
</head>
</html>
somedata

file2:
olga 81 91 B A
rene 82 92 B A
zack 83 93

Expextd Result:

somedata
<html>
<head>
olga 81 91 B A
rene 82 92 B A
zack 83 93
</head>
</html>


Thx in advance,
rajx
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-22-2007
Registered User
 

Join Date: Dec 2006
Posts: 7
Stumble this Post!
This code will create new file,

Code:
#!/usr/bin/ksh

file1="FileName1"
file2="FileName2"
Result="ResultFile"

for str in `cat $file1`
do
        if [ $str = "<head>" ]; then
                echo $str >> $Result
                echo `cat $file2` >> $Result
        else
                echo $str >> $Result
        fi
done
Reply With Quote
  #3 (permalink)  
Old 05-22-2007
Registered User
 

Join Date: May 2007
Posts: 4
Stumble this Post!
Thanks for your response,but i need following

I have two files:

FILE1:

somedata
<html>
<head>
This is sample statement
......
......
</head>
</html>
somedata

FILE2:

olga 81 91 B A
rene 82 92 B A
zack 83 93

Expextd Result:

FILE1:

somedata
<html>
<head>
olga 81 91 B A
rene 82 92 B A
zack 83 93
</head>
</html>

MY question is how to replace the file2 contents into file1 between the patteren <head> and</head>

Thx in advance,
rajx

Last edited by rajx; 05-22-2007 at 06:48 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0