title: Print column header next to column entry if condition match
body: <p>I am having a large file in the following format where 1st column is the id and then all are samples. I am trying to extract only ids for which only one sample is having value larger than 5 and remaining all have values less than 5. Additionally I also want to print the sample id along-with the sample value for which the value is greater than 5. Whats the best way to proceed it? I can identify all ids which full-fill the condition by following which I came across in the forum; but cannot get what I am expecting. </p>
  
  <pre><code> awk '{for(i=1;i&lt;=NF;i++) {if($i+0&gt;5) c++; printf "%-5s%s", $i, (i==NF? OFS c ORS: OFS)}c=0}' input.txt | awk 'NR==1{print $0}; NR&gt;1{if ($NF==1) print $0}
  </code></pre>
  
  <p>Input File</p>
  
  <pre><code>id      s1      s2      s3      s4      s5
  T1      203     3       0       1       80
  T2      70      2       0       0       1
  T3      50      66      90      321     15
  T4      1       4       2       1       10
  T5      0       0       0       0       2
  T6      2       1       2       11      2
  T7      200     3       1       0       0
  T8      15      11      9       8       1
  T9      1       23      1       2       1
  T10     34      1       1       2       1
  </code></pre>
  
  <p>Expected output</p>
  
  <pre><code>T2      s1      70
  T4      s5      10
  T6      s4      11
  T7      s1      200
  T9      s2      23
  T10     s1      34
  </code></pre>