 <p>This should do:</p> <pre><code>awk -F. '$1!=a &amp;&amp; NR&gt;1 {print ""} 1; {a=$1}' file foo.foo=Some string foo.bar=Some string bar.foo=Some string bar.bar=Some string baz.foo=Some string baz.bar=Some string </code></pre>