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 > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how do I replace a word in a file using DOS commands?? sabithareddym Windows & DOS: Issues & Discussions 1 05-22-2008 12:17 AM
replace words in file based on another file kinmak Shell Programming and Scripting 9 05-07-2008 05:06 AM
Replace word in a file sasiharitha UNIX for Dummies Questions & Answers 3 12-05-2007 01:11 AM
replace word in a file ust Shell Programming and Scripting 5 11-30-2007 08:03 PM
return a word between two words bryan UNIX for Dummies Questions & Answers 4 05-23-2006 01:56 PM

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

Join Date: Feb 2006
Posts: 8
How to replace a word with a series of words in a file

Hi,

I have a Template file 'TL.body' which says as follows:

"There are no <FILENAME> files on the server. "

The missing file names are identified and stored in a variable.
For Eg: MISSFILE="abc.txt def.txt xyz.txt"

I want the values of MISSFILE variable to be replaced against <FILENAME> and store the result in another Temp file.

I tried using the following command:
sed 's/<FILENAME>/'$MISSFILE'/g' TL.body > Temp.txt

However, it gives following error:
sed: Function s/<FILENAME>/abc.txt cannot be parsed.

Could somebody help me out to overcome this problem.

TIA

Regards,
Ramesh
  #2 (permalink)  
Old 02-21-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
The sed expression should be surrounded by double quotes.
Code:
sed "s/<FILENAME>/$MISSFILE/g" TL.body > Temp.txt
Or better yet
Code:
sed "s/.FILENAME./$MISSFILE/g" TL.body > Temp.txt
The . should take care of the meta-characters that need to be escaped.

Last edited by vino; 02-21-2006 at 01:50 AM..
  #3 (permalink)  
Old 02-21-2006
brap45 brap45 is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 8
Thanks a lot Vino... It works!
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 02:40 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