Re: Sed: replacing text with textfile content

From: Juergen Heck (btd.heck_at_t-online.de)
Date: 08/21/03


Date: Thu, 21 Aug 2003 16:42:56 +0200


Ek Strensom wrote:
>
> Can I use sed to replace a string of text in one file, with the
> entire contents of another file? I keep on running into
> problems with special characters....even when I use characters
> that don't occur in the HTML. :-(
>
> cat "${TEMPLATE}" | \
> sed "s@<!--#include VIRTUAL=\"ssi/css\"-->@`cat ~/public_html/ssi/css`@g" > \
> "${OUTFILE}"
>
> In this case, I want to replace the following text in the
> template:
>
> <!--#include VIRTUAL="ssi/css"-->
>
> With the entire contents of ~/public_html/ssi/css, before
> writing the output to a separate file.
>
> (Why I'm doing this with SSI is a long story. Most of my site
> features can use the SSI, except for a single page hosted by an
> outside site for CGI reasons. It would be easier to update the
> template like this when SSI specific code is updated (rarely).)
> --
> Ek Strensom
Untested

sed '/<!--#include VIRTUAL="ssi\/css"-->/'"d;r
$HOME/public_html/ssi/css" $TEMPLATE

Regards
Juergen



Relevant Pages

  • Re: Sed: replacing text with textfile content
    ... > Can I use sed to replace a string of text in one file, ... > template like this when SSI specific code is updated.) ... Or you could do the edscript like this: ...
    (comp.unix.shell)
  • Sed: replacing text with textfile content
    ... Can I use sed to replace a string of text in one file, ... (Why I'm doing this with SSI is a long story. ... outside site for CGI reasons. ... template like this when SSI specific code is updated.) ...
    (comp.unix.shell)
  • Re: Quanta templates
    ... Since I can't figure out what Quanta templates would be other than a pattern saved to use when you want to make a new one, I just do that -- I open an existent page, save it with a new filename, and edit it into what I want. ... As for making "a change to the basic design" necessitating "goto each individual page" to make changes, that's not the case here since I use CSS and PHP. ... In DW when I changed the template the change would reverberate to all of the pages that were based on that template. ... I know next to nothing about PHP and I am not sure how to use SSI. ...
    (alt.html)