title: Awk command to check if a particular string is present in a file, if present return the column names where this string is present
body: <p>Using the following awk command, I am able to check if a particular string is present in a file or not. </p>
  
  <pre><code>grep -R "statistics" &lt;Filename&gt;
  </code></pre>
  
  <p>But the output I am looking for is I need to find out the columns in which this string is present. Is there a way to extend this command so that it can return me the column names where this string is present.</p>
  
  <p>I tried the following command, but I am not getting the desired output</p>
  
  <pre><code>awk '{ for (i=1; i&lt;=NF; ++i) { if ($i = "statistics") print i } }' &lt;filename&gt;
  </code></pre>
  
  <p>There are around 1500 columns in my input file. It is a tab separated file with column headers included.</p>
  
  <p>Appreciate any guidance.</p>