Date: Thu, 2 Feb 2012 03:50:44 -0600 (CST) From: Robert Bonomi <bonomi@mail.r-bonomi.com> To: freebsd-questions@freebsd.org, guru@unixarea.de Subject: Re: some kind of binary sed(1) command Message-ID: <201202020950.q129oitm013971@mail.r-bonomi.com> In-Reply-To: <20120202080656.GA7403@sh4-5.1blu.de>
next in thread | previous in thread | raw e-mail | index | archive | help
> From: Matthias Apitz <guru@unixarea.de> > > 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}/'
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202020950.q129oitm013971>