title: Bash: how do i peek and save the first line of stdin
body: <p>I have a set files that when cat'ed together have the format</p>
  
  <pre><code>NAME1.1 NAME2.1 NAME3.1 KEY1 VALUE1.1 KEY2 VALUE2.1
  NAME1.2 NAME2.2 NAME3.2 KEY1 VALUE1.2 KEY2 VALUE2.2
  ...
  NAME1.N NAME2.N NAME3.N KEY1 VALUE1.N KEY2 VALUE2.N
  </code></pre>
  
  <p>and reading through the key value pair text is quote tedious so I thought a processing script is in order so I wrote this</p>
  
  <pre><code>#!/bin/bash
  cat "$@" \
      | head -n1 \
      | awk '{printf("NAME1 NAME2 NAME3 ");for(i=4;i&lt;NF;i+=2){printf("%s ",$i)}printf("\n")}'
  
  cat "$@" \
      |awk '{printf("%s %s %s ",$1,$2,$3);for(i=5;i&lt;=NF;i+=2){printf("%s ",$i)}printf("\n")}'
  </code></pre>
  
  <p>As you can see I am playing the files twice just to grab the header row so I can get the values and format them as</p>
  
  <pre><code>NAME1   NAME2   NAME3   KEY1     KEY2
  NAME1.1 NAME2.1 NAME3.1 VALUE1.1 VALUE2.1
  NAME1.2 NAME2.2 NAME3.2 VALUE1.2 VALUE2.2
  ...
  NAME1.N NAME2.N NAME3.N VALUE1.N VALUE2.N
  </code></pre>
  
  <p>Is there a good way to peek and copy the first line so I can save it?</p>
  
  <p>I've tried a one liner like this</p>
  
  <pre><code>( cat *.all_my_files \
    | tee &gt;( head -n1 | awk '{printf("NAME1 NAME2 NAME3 ");for(i=4;i&lt;NF;i+=2){printf("%s ",$i)}printf("\n")}' ) \
    | awk '{printf("%s %s %s ",$1,$2,$3);for(i=5;i&lt;=NF;i+=2){printf("%s ",$i)}printf("\n")}' \
    ) | column -t
  </code></pre>
  
  <p>but this seems to exit when either of the stdouts finish giving me an indeterminate amount of output</p>