title: Bash (v.2.03) capture awk output to array not working
body: <p>I am struggling around with awk and want to save the awk output <strong>separated by the delimiter</strong> to array. So just to have this working:</p>
  
  <pre><code>array[index]=$line
  </code></pre>
  
  <p>with <code>$line</code> equal value between separator <code>'[[:blank:]]{2,}'</code> in the desired file.</p>
  
  <p>I tried already multiple solutions like:</p>
  
  <pre><code>myarr=$(/usr/xpg4/bin/awk -F '[[:blank:]]{2,}' 'FNR &gt; 4 { for (i=1; i&lt;=NF; i++) if ($i != "") print $i;}' my-file)
  </code></pre>
  
  <p>or </p>
  
  <pre><code>array=()
  counter=0
  /usr/xpg4/bin/awk -F '[[:blank:]]{2,}' 'FNR &gt; 4 { for (i=1; i&lt;=NF; i++) if ($i != "") print $i;}' my-file | while read -r line; do
      array[counter]=$line
      counter=$((counter+1))
  done
  
  echo ${#array[@]}
  echo ${array[1]}
  </code></pre>
  
  <p>none of them produce the desired result. But when I modify the second case and <code>echo</code> the <code>$line</code> and the <code>$counter</code> I get the array, but it is not the case for a large file, I just do not want to output the whole lines to the console to get my array filled up - it makes no sense for me:</p>
  
  <p><strong>This works -> but uggly/bad performance for large files</strong></p>
  
  <pre><code>array=()
  counter=0
  /usr/xpg4/bin/awk -F '[[:blank:]]{2,}' 'FNR &gt; 4 { for (i=1; i&lt;=NF; i++) if ($i != "") print $i;}'my-file | while read -r line; do
      echo $line
      echo $counter
      array[counter]=$line
      counter=$((counter+1))
  done
  
  echo ${#array[@]}
  echo ${array[1]}
  </code></pre>