title: Awk Command not working as it should, output is wrong, sed command?
body: <p>I tried this little script on my dataset and for some reason I am not getting the desired output? can someone have a look ? Maybe you can figure it out? Also if you could offer a SED command solution. </p>
  
  <p>Script</p>
  
  <pre><code>awk -v RS= -F '&lt;connection name="|&lt;hostPort&gt;' '
  {
  sub(/".*/, "", $2)
  split($3, tokens, /[:&lt;]/)
  printf "%-6s %s %s\n", $2, tokens[1], tokens[2]
  }
  '
  </code></pre>
  
  <p>input</p>
  
  <pre><code>&lt;hostPort&gt;srv1:33333&lt;/hostPort&gt;
  &lt;hostPort&gt;srv2:33333&lt;/hostPort&gt;
  &lt;connection name="boing_ny__Primary__" transport="tcp"&gt;
  &lt;hostPort&gt;srv1:33333&lt;/hostPort&gt;
  &lt;connection name="boing_ny__Backup__" transport="tcp"&gt;
  &lt;hostPort&gt;srv2:33333&lt;/hostPort&gt;
  &lt;connection name="boy_ny__Primary__" transport="tcp"&gt;
  &lt;hostPort&gt;srv1:6666&lt;/hostPort&gt;
  &lt;connection name="boy_ny__Backup__" transport="tcp"&gt;
  &lt;hostPort&gt;srv2:6666&lt;/hostPort&gt;
  &lt;connection name="song_ny__Primary__" transport="tcp"&gt;
  &lt;hostPort&gt;srv1:55555&lt;/hostPort&gt;
  &lt;connection name="song_ny__Backup__" transport="tcp"&gt;
  &lt;hostPort&gt;srv2:55555&lt;/hostPort&gt;
  &lt;connection name="bob_ny__Primary__" transport="tcp"&gt;
  &lt;hostPort&gt;srv3:33333&lt;/hostPort&gt;
  &lt;connection name="bob_ny__Backup__" transport="tcp"&gt;
  &lt;hostPort&gt;srv4:33333&lt;/hostPort&gt;
  &lt;hostPort&gt;srv1:4444&lt;/hostPort&gt;
  &lt;hostPort&gt;srv2:4444&lt;/hostPort&gt;
  &lt;hostPort&gt;srv1:4444&lt;/hostPort&gt;
  </code></pre>
  
  <p>Current output</p>
  
  <pre><code>srv1:33333&lt;/hostPort&gt;
  srv2 33333
  </code></pre>
  
  <p>desired output</p>
  
  <pre><code>boing_ny__Primary__  srv1 33333
  boing_ny__Backup__   srv2 33333
  boy_ny__Primary__     srv1 6666
  boy_ny__Backup__   srv2 6666
  song_ny__Primary__ srv1 55555
  song_ny__Backup__ srv2 55555
  bob_ny__Primary__ srv3 33333
  bob_ny__Backup__ srv4 33333
  </code></pre>