sed error "unescaped newline inside substitute pattern"

Frank Shute frank at shute.org.uk
Thu Mar 12 17:13:20 PDT 2009


On Thu, Mar 12, 2009 at 01:34:36PM -0400, David Banning wrote:
>
> Here is the php line that gives the error;
> 
> cat start_text | sed "s/--maintext--/$test/" > endtext
> 
> give error;
> 
> sed: 1: "s/--maintext--/ Comment ...": unescaped newline inside substitute pattern
> 
> where $test contains customer input from a website form
> 
> There is something about the content of the text within the variable $test that is causing the error.
> 
> Any pointers would be helpful.

I think your problem is that $ is an end of line as a regex. So sed is
choking on the fact that there's some text ("test") after the end of
line.

I can't really tell you how to fix it, although backslash escaping the
$ might be worth a try.

Regards,

-- 

 Frank 


 Contact info: http://www.shute.org.uk/misc/contact.html 



More information about the freebsd-questions mailing list