how to set field name as file name bash/awk
<p>I have a file with 500 columns and I would need to split each column into a new file while printing $1 as common in all the files. Below is a sample file, and I managed to do this using the below bash/awk solution :</p>

<pre><code>ID    F1    F2    F4    F4
aa    1    2    3    4 
bb    1    2    3    4
cc    1    2    3    4
dd    1    2    3    4

num=('1' '2' '3' '4')
for i in ${num[@]}; do awk -F "\t" -v col="$i" '{print $1,$col}' OFS="\t"        
Input.txt &gt; ${i}.txt; done
</code></pre>

<p>which gives the required output as:</p>

<pre><code>1.txt
ID    ID
aa    aa
bb    bb
cc    cc
dd    dd

2.txt
ID    F1
aa    1
bb    1
cc    1
dd    1

....
</code></pre>

<p>However, I could not track which file corresponds to which column as the output file name is the field number but not the field name. Could it be possible to write the header of the field as prefix to the output file name? </p>

<pre><code>ID.txt
ID    ID
aa    aa
bb    bb
cc    cc
dd    dd

F1.txt
ID    F1
aa    1
bb    1
cc    1
dd    1
</code></pre>