title: Bash: DNS lookup, put NS in array
body: <p>I need to lookup the NS for a couple of domains and I need to put the results in an array.
  Right now I have only manage to get the first result to echo but I need all the results, preferably in an array.</p>
  
  <p>Does anyone know how to do that?</p>
  
  <p>For example, <code>dig google.com ns</code> gives me 4 results <code>ns[1-4].google.com</code>
  I've just done this:</p>
  
  <pre><code>dig google.com ns | awk '/^;; ANSWER SECTION:$/ { getline ; print $5 '} 
  </code></pre>
  
  <p>But that only prints the first line. I have no idea how to put all the results in an array.</p>