Bug in sed(1)?

Sam Kendall sam at delftcc.UUCP
Sat Jan 25 12:30:31 AEST 1986


In article <685 at ttrdc.UUCP>, levy at ttrdc.UUCP (Daniel R. Levy) writes:
> I have encountered what I THINK is a bug in sed(1)....
> 
> Specifically, it involves expressions of the form '1,/^fixed_pattern$/d'....
> 
> Unfortunately, this seems to fail when the first line of the input exactly
> matches fixed_pattern; then, instead of only the first line of the input
> being discarded, ALL the lines of input are discarded.

As another news item noted, this is documented behavior.  To work around
it, prepend a blank line to the input stream:

	( echo; cat ) | sed '1,/^fixed_pattern$/d'

This does exactly what you want.

I think it is possible to work around this in a single sed process,
using the pattern space, but I the result would be very ugly!

----
Sam Kendall			     allegra \
Delft Consulting Corp.		seismo!cmcl2  ! delftcc!sam
+1 212 243-8700			       ihnp4 /
ARPA: delftcc!sam at nyu.ARPA



More information about the Net.bugs.usg mailing list