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 !!

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-28-2008
Registered User
 

Join Date: Apr 2008
Posts: 46
sed

i have files: username.txt and passwword.txt and sourcefile.txt

username.txt contains tjmannonline
password.txt contains abc123

username=`tail username.txt'
passwd=`tail password.txt'

my sourcefile.txt contains:

<RDID><![CDATA[USERNAME]]></RDID>
<user><![CDATA[USERNAME]]></user>
<password><![CDATA[PASSWORD]]></password>

sed -e 's/USERNAME/$username/g' sourcefile.txt > sourcefile.txt1
sed -e 's/PASSWORD/$passwd/g' sourcefile.txt1 > sourcefile.txt2

all said and done, i'd like to have this result:

<RDID><![CDATA[tjmannonline]]></RDID>
<user><![CDATA[tjmannonline]]></user>
<password><![CDATA[abc123]]></password>

sed -e 's/USERNAME/$username/g' did not replace USERNAME with tjmannonline, it replaced it with $username.
Reply With Quote
Forum Sponsor
  #2  
Old 07-28-2008
Registered User
 

Join Date: Apr 2008
Posts: 46
never mind. i searched via unix.com, and sed -e 's/USERNAME/'${username}'/g took care my question. once again, thanks to unix.com
Reply With Quote
  #3  
Old 07-28-2008
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
Great !

Thats what I keep saying, please do search the forum before posting.

Now the search code would be happy !
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:47 PM.


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

Content Relevant URLs by vBSEO 3.2.0