From owner-freebsd-questions@FreeBSD.ORG Thu Nov 10 00:09:24 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B0088106564A for ; Thu, 10 Nov 2011 00:09:24 +0000 (UTC) (envelope-from lenthe@comcast.net) Received: from qmta13.westchester.pa.mail.comcast.net (qmta13.westchester.pa.mail.comcast.net [76.96.59.243]) by mx1.freebsd.org (Postfix) with ESMTP id 751438FC0A for ; Thu, 10 Nov 2011 00:09:24 +0000 (UTC) Received: from omta22.westchester.pa.mail.comcast.net ([76.96.62.73]) by qmta13.westchester.pa.mail.comcast.net with comcast id v8B31h0071ap0As5DBw9Lo; Wed, 09 Nov 2011 23:56:09 +0000 Received: from [192.168.1.101] ([68.42.13.245]) by omta22.westchester.pa.mail.comcast.net with comcast id vBw81h01y5HDiR83iBw9yR; Wed, 09 Nov 2011 23:56:09 +0000 Message-ID: <4EBB1317.5060101@comcast.net> Date: Wed, 09 Nov 2011 18:56:07 -0500 From: Jason Lenthe User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:5.0) Gecko/20110815 Thunderbird/5.0 MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <4EBA5646.5030102@unsane.co.uk> In-Reply-To: <4EBA5646.5030102@unsane.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: sed vs gnu sed X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Nov 2011 00:09:24 -0000 On 11/09/11 05:30, Vincent Hoffman wrote: > 'Hi all, > I'm trying to move a script from a linux box to a freebsd box. > All going well as its just a bash script and bash is bash, however there > is one line I'm unable to use directly, as bsd sed (correctly according > to SUS at least, I believe[1]) appends a newline when writing to > standard out, gnu sed doesnt. example > BSD > [backup@banshee ~]$ echo -n "/boot:7:1:5; /:7:1:5; /var:7:1:5" | sed -n > 's/[[:space:]]*;[[:space:]]*/;/gp' > /boot:7:1:5;/:7:1:5;/var:7:1:5 > [backup@banshee ~]$ > > LINUX > > [backup@amber ~]$ echo -n "/boot:7:1:5; /:7:1:5; /var:7:1:5" | sed > 's/[[:space:]]*;[[:space:]]*/;/g' > /boot:7:1:5;/:7:1:5;/var:7:1:5[backup@amber ~]$ > > is there any easy way to make our sed do the same as gnu sed here? > You could also just lop off the newline with tr -d '\n': echo -n "/boot:7:1:5; /:7:1:5; /var:7:1:5" | sed -n 's/[[:space:]]*;[[:space:]]*/;/gp' | tr -d '\n'