From owner-freebsd-questions@FreeBSD.ORG Thu Feb 2 09:46:33 2012 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 EC3421065673 for ; Thu, 2 Feb 2012 09:46:32 +0000 (UTC) (envelope-from bonomi@mail.r-bonomi.com) Received: from mail.r-bonomi.com (mx-out.r-bonomi.com [204.87.227.120]) by mx1.freebsd.org (Postfix) with ESMTP id 99CBA8FC0C for ; Thu, 2 Feb 2012 09:46:32 +0000 (UTC) Received: (from bonomi@localhost) by mail.r-bonomi.com (8.14.4/rdb1) id q129oitm013971; Thu, 2 Feb 2012 03:50:44 -0600 (CST) Date: Thu, 2 Feb 2012 03:50:44 -0600 (CST) From: Robert Bonomi Message-Id: <201202020950.q129oitm013971@mail.r-bonomi.com> To: freebsd-questions@freebsd.org, guru@unixarea.de In-Reply-To: <20120202080656.GA7403@sh4-5.1blu.de> Cc: Subject: Re: some kind of binary sed(1) command 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, 02 Feb 2012 09:46:33 -0000 > From: Matthias Apitz > > El dia Thursday, February 02, 2012 a las 01:51:56AM -0600, Robert Bonomi escribio: > > Thanks, but the attached script (based on your content and saved to a > script file) just gives: *sigh* the code worked wih gnu sed. BSD sed is a whole lot more finicky with regard to whitespace. And, it appears that I've got some bug reports to file. Anyway, this is tested on FBSD 7.2: copy _exactly_, making sure there is no trailing white-space on any line. Then substitute an actual formfeed char for the {CTL-L}. FreeBSD sed does not recognize either '\n' or '\f' in the substitution string -- it strips the '\' and outputs the printable character. *sigh* #!/bin/sh sed -e ' :l /^[*][*]*$/ N /\n..*$/ P /\n..*$/ { s/^.*\n// b l } /\n$/ N /\n\n[^*][^*]*$/ { P s/^.*\n// P s/^.*\n// b l } /\n\n[*]*$/ s/\n\n/\ {CTL-L}/'