some kind of binary sed(1) command

Robert Bonomi bonomi at mail.r-bonomi.com
Thu Feb 2 09:46:33 UTC 2012


> From: Matthias Apitz <guru at 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}/'



More information about the freebsd-questions mailing list