 <p>A little whitespace will go a long way...</p> <p>The opposite of <code>$0 ~ s</code> is <code>$0 !~ s</code>, so</p> <pre><code>cvs -q status | awk ' c-- &gt; 0 $0 !~ s { if (b) for (c=b+1; c&gt;1; c--) print r[(NR-c+1)%b] print c=a } b {r[NR%b]=$0} ' b=1 a=9 s='Up-to-date' </code></pre>