From owner-freebsd-questions@FreeBSD.ORG Wed Nov 9 11:27:40 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 13C20106566C for ; Wed, 9 Nov 2011 11:27:40 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (smtp6.infracaninophile.co.uk [IPv6:2001:8b0:151:1:3fd3:cd67:fafa:3d78]) by mx1.freebsd.org (Postfix) with ESMTP id 7C2BB8FC0C for ; Wed, 9 Nov 2011 11:27:39 +0000 (UTC) Received: from seedling.black-earth.co.uk (seedling.black-earth.co.uk [81.187.76.163]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.5/8.14.5) with ESMTP id pA9BRYcB074844 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 9 Nov 2011 11:27:35 GMT (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: OpenDKIM Filter v2.4.1 smtp.infracaninophile.co.uk pA9BRYcB074844 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infracaninophile.co.uk; s=201001-infracaninophile; t=1320838056; bh=f75nmdrbDl31QVwjuIlMnoNqE1IZkalHmXtGfFvHArQ=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=WxbdsjYFcQ9YpmvAe4SFYgf/LnBnIKlctfhuGGRlk95vW5GRT6pDN3So9yOCXQhQj GqA8XrGEBP9/9cgYPdL3maT/ks8kY48J2l9kdWeKJPGB1Vg74W/JK4mA4amuVSV+TV 18uOowf+UFrghVjVVt+9Am5IrTonHYraVqWf4scw= Message-ID: <4EBA63A6.7070006@infracaninophile.co.uk> Date: Wed, 09 Nov 2011 11:27:34 +0000 From: Matthew Seaman User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: Vincent Hoffman 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 X-Virus-Scanned: clamav-milter 0.97.3 at lucid-nonsense.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_FAIL autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on lucid-nonsense.infracaninophile.co.uk Cc: "FreeBSD-Questions@freebsd.org" 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: Wed, 09 Nov 2011 11:27:40 -0000 On 09/11/2011 10:30, Vincent Hoffman wrote: > is there any easy way to make our sed do the same as gnu sed here? > for now I have encapsulated the whole thing in a subshell > [backup@banshee ~]$ echo -n $(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 ~]$ > > Which works but seems a little hackish. You can do it with awk(1): # echo -n "/boot:7:1:5; /:7:1:5; /var:7:1:5" | \ awk ' { gsub("[[:space:]]*;[[:space:]]*", ";", $0) ; printf "%s", $0 }' Not sure if that's any better than your solution using echo though. Also trivial in perl(1) or python(1) or whatever, but it seems a waste to fire up a whole perl interpreter just to do that. Cheers, Matthew -- Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate JID: matthew@infracaninophile.co.uk Kent, CT11 9PW