is there a way of usinf greo to find 3 or 4 blank lines?

Mark Willson cdr.nil at gmail.com
Sun Sep 6 20:40:07 UTC 2009


Gary Kline wrote:
> in my manuscript, i have many places where i'ved used several
> newlines to indicate a jump in time, or topic, or mood, or
> <<whatever>>.  i have lost these vertical spacing in all but my
> original draft.  can i use grep somehow to find these extra newlines?
> 
> 
> if not grep, then sed, ed, or what?!
> 
> tia,
> 
> gary
> 
> 
> 
Gary,

If I understand your question correctly (by no means certain), the
following may help.  This is an awk script, which will print out the
lines in the source file at which it finds more than three consecutive
empty lines.

BEGIN {
     ncnt = 0
}
/^ *$/ {
	ncnt++;
         if (ncnt > 3)
		{print "Emphasis at: " NR;
		 ncnt = 0;}
	 next;
	}
        {ncnt = 0;}

You can invoke this (assuming the awk source in is a file called
"em.awk" and your original manuscript is in a file called "manuscript") by:

$ awk -f em.awk manuscript

-mark



More information about the freebsd-questions mailing list