title: How can I assign each column value to Its name?
body: <p>I have a MetaData.csv file that contains many values to perform an analysis. All I want are:
  1- Reading column names and making variables similar to column names.
  2- Put values in each column into variables as an integer that can be read by other commands. column_name=Its_value</p>
  <p>MetaData.csv:</p>
  <pre><code>MAF,HWE,Geno_Missing,Inds_Missing
  0.05,1E-06,0.01,0.01
  </code></pre>
  <p>I wrote the following codes but it doesn't work well:</p>
  <pre><code>#!/bin/bash
  Col_Names=$(head -n 1 MetaData.csv) # Cut header (camma sep)
  Col_Names=$(echo ${Col_Names//,/ }) # Convert header to space sep
  Col_Names=($Col_Names) # Convert header to an array 
  
  for i in $(seq 1 ${#Col_Names[@]}); do
  N=&quot;$(head -1 MetaData.csv | tr ',' '\n' | nl |grep -w 
  &quot;${Col_Names[$i]}&quot; | tr -d &quot; &quot; | awk -F &quot; &quot; '{print $1}')&quot;;
  ${Col_Names[$i]}=&quot;$(cat MetaData.csv | cut -d&quot;,&quot; -f$N | sed '1d')&quot;;
  done
  </code></pre>
  <p>Output:</p>
  <pre><code>HWE=1E-06: command not found
  Geno_Missing=0.01: command not found
  Inds_Missing=0.01: command not found
  cut: 2: No such file or directory
  cut: 3: No such file or directory
  cut: 4: No such file or directory
  =: command not found
  </code></pre>
  <p>Expected output:</p>
  <pre><code>MAF=0.05
  HWE=1E-06
  Geno_Missing=0.01
  Inds_Missing=0.01
  </code></pre>
  <p>Problems:</p>
  <p>1- I want to use array length (${#Col_Names[@]}) as the final iteration which is 5, but the array index start from 0 (0-4). So MAF column was not captured by the loop. Loop also iterate twice (once 0-4 and again 2-4!).
  2- When I tried to call values in variables (echo $MAF), they were empty!</p>
  <p>Any solution is really appreciated.</p>