![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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-21-2008 09:17 PM |
| replace words in file based on another file | kinmak | Shell Programming and Scripting | 9 | 05-07-2008 02:06 AM |
| Replace word in a file | sasiharitha | UNIX for Dummies Questions & Answers | 3 | 12-04-2007 10:11 PM |
| replace word in a file | ust | Shell Programming and Scripting | 5 | 11-30-2007 05:03 PM |
| return a word between two words | bryan | UNIX for Dummies Questions & Answers | 4 | 05-23-2006 10:56 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
The sed expression should be surrounded by double quotes.
Code:
sed "s/<FILENAME>/$MISSFILE/g" TL.body > Temp.txt Code:
sed "s/.FILENAME./$MISSFILE/g" TL.body > Temp.txt Last edited by vino; 02-20-2006 at 10:50 PM. |
|
#3
|
|||
|
|||
|
Thanks a lot Vino... It works!
|
|||
| Google The UNIX and Linux Forums |