logo       

Re: Replacing a pattern in one file by reading a string from another file: msg#00002

editors.sed.user

Subject: Re: Replacing a pattern in one file by reading a string from another file

> File1 contents: [File1 has just this one string and nothing else]
> 11212005
>
> File2 Contents:
> BeginDate=$crtdate
>
> In file2 $crtdate occurs multiple times and I am trying to use a SED
> script to replace the $crtdate in file2 with the "11212005" from file1.

Assuming File1 doesn't contain any sed metacharacters and adheres
to your description that the one string is the only thing in the
file, the following

sed 's/$crtdate/'`cat File1`'/g' File2

seems to work for me (note the various flavors of quotes). I
don't know if in versions of sed other than the GNU version I'm
using here, if you'd have to escape the "$" with a backslash.

-tim







------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/I258zB/QnQLAA/TtwFAA/dkFolB/TM
--------------------------------------------------------------------~->

--

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/sed-users/

<*> To unsubscribe from this group, send an email to:
sed-users-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/






<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise