Chris Arnold schreef:
> $ sed -i 's/red/blue/g' file
> 
> to replace every entry called red with one that's called blue and write it in 
> the file(-i). You can of course use such things as ./* for the hole 
> directory....
> 
> man sed or man awk will provide you with further informations :)
> 
> I have a long replacement text like this:
> <?php require('../../wp-blog-header.php'); ?><?php get_header(); ?><?php 
> include(TEMPLATEPATH."/sidebar1.php");?><div id="main"><div id="content">
> 
> and the text that needs to be replaced is:
> <HTML><HEAD><TITLE>Net Bible - Genesis </TITLE><LINK REL=Stylesheet 
> HREF="style.css" TYPE="text/css" MEDIA=screen></HEAD><body><p class=title>
> 
> So the command i run looks like this; sed -i 's/<HTML><HEAD><TITLE>Net Bible 
> - Genesis </TITLE><LINK REL=Stylesheet HREF="style.css" TYPE="text/css" 
> MEDIA=screen></HEAD><body><p class=title>/<?php 
> require('../../wp-blog-header.php'); ?><?php get_header(); ?><?php 
> include(TEMPLATEPATH."/sidebar1.php");?><div id="main"><div id="content">/g' 
> ./*
> 
> and i get this error:
> sed: -e expression #1, char 99: unknown option to `s'

There are a couple of reasons why this does not work. First and foremost: since
your replacement text contains '/', you should use a text separator different
from '/' like
s#foo#bar#g

If I remember correctly < and > are also special (have to look that up) and you
should escape them: \< and \>.

Finally, this would only work on a consecutive text without newlines and I think
that is not what you have in mind.

Look up the c command in sed, because I think that is what you need. This lets
you replace a couple of lines with a couple of other lines.
-- 
Jos van Kan                registered Linux user #152704
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to