From owner-freebsd-questions Wed Dec 30 08:32:58 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id IAA00932 for freebsd-questions-outgoing; Wed, 30 Dec 1998 08:32:58 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from bogslab.ucdavis.edu (bogslab.ucdavis.edu [169.237.68.34]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id IAA00922 for ; Wed, 30 Dec 1998 08:32:50 -0800 (PST) (envelope-from greg@bogslab.ucdavis.edu) Received: from deal1.bogs.org (deal1.bogs.org [198.137.203.51]) by bogslab.ucdavis.edu (8.7.4/8.7.3) with ESMTP id IAA13235; Wed, 30 Dec 1998 08:32:19 -0800 (PST) Received: from deal1.bogs.org (localhost [127.0.0.1]) by deal1.bogs.org (8.8.8/8.6.12) with ESMTP id IAA21206; Wed, 30 Dec 1998 08:32:17 -0800 (PST) Message-Id: <199812301632.IAA21206@deal1.bogs.org> Cc: Greg Black To: questions@FreeBSD.ORG Subject: Re: Sed sillyness (stupid question?) In-reply-to: Your message of "Wed, 30 Dec 1998 20:56:15 +1000." <19981230105616.7077.qmail@alice.gba.oz.au> Reply-To: gkshenaut@ucdavis.edu Date: Wed, 30 Dec 1998 08:32:16 -0800 From: Greg Shenaut Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <19981230105616.7077.qmail@alice.gba.oz.au>, Greg Black cleopede: >> Why doesnt this work: >> >> sed 's,test,te\nst,' >> >> That is when test is found how come sed doesnt actually print the newline >> character? > >What you need is: > >sed 's,test,te\ >st,' > >In other words, you need a real backslash character followed by >a real newline character -- not some code for it like "\n". To avoid splitting the sed command across two lines, sometimes something like this helps (at least under (pd)ksh): NL="\\^J" (to get ^J, type CTL-V CTL-J) ... sed -e "s/xyz/xx${NL}yy/" ... or, you can set NL="^J" and use "s/xyz/xx\\${NL}yy/", same difference. Note that you have to use "" for the sed expression with this method, not ''. -Greg Shenaut To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message