title: Take file as an input and run awk command on it
body: <p>I have a awk command which works fine when I run it directly on my terminal. However, now I want to take make a bash script that takes a file name as input and then runs the same awk command on it and saves the output. How can I achieve the? My awk command is:</p>
  <pre><code>
  awk -F, '/^#/ {next;} /^VariantID/ {printf(&quot;##fileformat=VCFv4.2\n&quot;);split($0,header);for(i=5;i&lt;=NF;i++) printf(&quot;##INFO=&lt;ID=%s,Number=1,Type=String,Description=\&quot;%s\&quot;&gt;\n&quot;,$i,$i);printf(&quot;#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n&quot;);next ;} {printf(&quot;%s\t%s\t%s\t%s\t%s\t.\t.\t&quot;,$2,$3,$1,$5,$6);for(i=5;i&lt;=NF;i++) printf(&quot;%s=%s;&quot;,header[i],$i);printf(&quot;\n&quot;);}' &gt; atlas.chr2.vcf
  
  </code></pre>
  <p>I want to put this is in a bash script which takes filename as input and then run awk command on it so something like:</p>
  <pre><code>#!/bin/bash
  
  ##Take filename as input
  
  
  ###Run awk command on it and the output in a file:
  awk -F, '/^#/ {next;} /^VariantID/ {printf(&quot;##fileformat=VCFv4.2\n&quot;);split($0,header);for(i=5;i&lt;=NF;i++) printf(&quot;##INFO=&lt;ID=%s,Number=1,Type=String,Description=\&quot;%s\&quot;&gt;\n&quot;,$i,$i);printf(&quot;#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n&quot;);next ;} {printf(&quot;%s\t%s\t%s\t%s\t%s\t.\t.\t&quot;,$2,$3,$1,$5,$6);for(i=5;i&lt;=NF;i++) printf(&quot;%s=%s;&quot;,header[i],$i);printf(&quot;\n&quot;);}' &gt; atlas.chr2.vcf
  
  </code></pre>
  <p>Insights will be appreciated.</p>