 <p>I am assuming the following format:</p> <pre><code>word definitionkey : definitionvalue [definitionkey : definitionvalue …] </code></pre> <p>None of those elements may contain a space and they are always delimited by a single space.</p> <p>The following code should work:</p> <pre><code>awk '{ for (i=2; i&lt;=NF; i+=3) print $1, $i, $(i+1), $(i+2) }' file </code></pre> <p>Explanation (this is the same code but with comments and more spaces):</p> <pre><code>awk ' # match any line { # iterate over each "key : value" for (i=2; i&lt;=NF; i+=3) print $1, $i, $(i+1), $(i+2) # prints each "word key : value" } ' file </code></pre> <p><code>awk</code> has some tricks that you may not be familiar with. It works on a line-by-line basis. Each stanza has an optional conditional before it (<code>awk 'NF &gt;=4 {…}'</code> would make sense here since we'll have an error given fewer than four fields). <code>NF</code> is the number of fields and a dollar sign (<code>$</code>) indicates we want the value of the given field, so <code>$1</code> is the value of the first field, <code>$NF</code> is the value of the last field, and <code>$(i+1)</code> is the value of the third field (assuming <code>i=2</code>). <code>print</code> will default to using spaces between its arguments and adds a line break at the end (otherwise, we'd need <code>printf "%s %s %s %s\n", $1, $i, $(i+1), $(i+2)</code>, which is a bit harder to read).</p>