From owner-freebsd-questions@FreeBSD.ORG Fri Mar 13 00:13:20 2009 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 004D7106566C for ; Fri, 13 Mar 2009 00:13:19 +0000 (UTC) (envelope-from frank@esperance-linux.co.uk) Received: from mailout.zetnet.co.uk (mailout.zetnet.co.uk [194.247.47.231]) by mx1.freebsd.org (Postfix) with ESMTP id AF2D08FC13 for ; Fri, 13 Mar 2009 00:13:19 +0000 (UTC) (envelope-from frank@esperance-linux.co.uk) Received: from irwell.zetnet.co.uk ([194.247.47.48] helo=zetnet.co.uk) by mailout.zetnet.co.uk with esmtp (Exim 4.63) (envelope-from ) id 1Lhv1W-0002ox-WF; Fri, 13 Mar 2009 00:13:15 +0000 Received: from melon.esperance-linux.co.uk (54-144.adsl.zetnet.co.uk [194.247.54.144]) by zetnet.co.uk (8.14.1/8.14.1/Debian-9) with ESMTP id n2D0DDut003808; Fri, 13 Mar 2009 00:13:13 GMT Received: by melon.esperance-linux.co.uk (Postfix, from userid 1001) id 5FC9EFCA4DB; Fri, 13 Mar 2009 00:13:08 +0000 (GMT) Date: Fri, 13 Mar 2009 00:13:08 +0000 From: Frank Shute To: David Banning Message-ID: <20090313001308.GA94751@melon.esperance-linux.co.uk> References: <20090312173436.GA51898@skytracker.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090312173436.GA51898@skytracker.ca> User-Agent: Mutt/1.4.2.3i X-Face: *}~{PHnDTzvXPe'wl_-f%!@+r5; VLhb':*DsX%wEOPg\fDrXWQJf|2\,92"DdS%63t*BHDyQ|OWo@Gfjcd72eaN!4%NE{0]p)ihQ1MyFNtWL X-Operating-System: FreeBSD 6.4-RELEASE-p2 i386 X-Organisation: 'http://www.shute.org.uk/' X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.1.7 (zetnet.co.uk [194.247.46.1]); Fri, 13 Mar 2009 00:13:14 +0000 (GMT) Cc: questions@freebsd.org Subject: Re: sed error "unescaped newline inside substitute pattern" X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Frank Shute List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2009 00:13:20 -0000 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