The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 06:47 PM
Replacement of Delimiter panknil Shell Programming and Scripting 3 05-14-2007 07:35 AM
Replacement using sed handak9 UNIX for Dummies Questions & Answers 5 07-13-2004 11:28 AM
cpu replacement. help IMPTRUE UNIX for Dummies Questions & Answers 3 07-25-2003 08:40 AM
global replacement Babu UNIX for Dummies Questions & Answers 2 07-04-2001 09:02 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-21-2007
rajx rajx is offline
Registered User
  
 

Join Date: May 2007
Posts: 4
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
  #2 (permalink)  
Old 05-22-2007
asmita asmita is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 7
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
  #3 (permalink)  
Old 05-22-2007
rajx rajx is offline
Registered User
  
 

Join Date: May 2007
Posts: 4
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 09:48 AM..
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0