title: Extracting data from multiple variable sized arrays in bash onto one line
body: <p>I am writing a small bash script that will find the MX records of any given domain, then print out the hostname, IP address, and reverse address for the IP address. I was able to successfully store each hostname, ip, and reverse address into 3 arrays:</p>
  
  <pre><code>$MXHOSTS[@]
  $MXIPS[@]
  $MXRHOST[@]
  </code></pre>
  
  <p>Each contains the same number of values, and depend on how many MX records a domain has. What I want to then do, is print out a line with data from all three arrays, for the number of values in the arrays.</p>
  
  <p>How would I be able to either a. create a new array that condenses 3 arrays into 1 with this data or b. print out the data from all three arrays using echo?</p>
  
  <p>Examples:</p>
  
  <pre><code>$MXHOSTS[0] = aspmx.l.google.com.
  $MXIPS[0] = 74.125.129.27
  $MXRHOST[0] = ia-in-f27.1e100.net.
  </code></pre>
  
  <p>From that, I'd like to then print out this:</p>
  
  <p>aspmx.l.google.com. :: 74.125.129.27 :: ia-in-f27.1e100.net.</p>
  
  <p>for each MX record, so it would run like this:</p>
  
  <pre><code>[~/scripts]# ./whomails google.com
  aspmx.l.google.com. :: 74.125.129.27 :: ia-in-f27.1e100.net.
  alt1.aspmx.l.google.com. :: 74.125.129.27 :: qe-in-f27.1e100.net.
  </code></pre>
  
  <p>etc..</p>
  
  <p>So far I've tried a few different methods, mostly using for loops, but if the domain has multiple MX records it will print out all possible combinations. With only one MX, it works fine.</p>
  
  <p>Currently I am using the following, but this is what gives me all possible combinations:</p>
  
  <pre><code>for hosts in "${MXHOSTS[@]}"; do
      for ips in "${MXIPS[@]}"; do
          for rhosts in "${MXRHOSTS[@]}"; do
              echo "$hosts :: $ips :: $rhosts"
          done
      done
  done
  </code></pre>
  
  <p>How do I get it to print just the corresponding array value, like [1-n] instead of [@]*[@]*[@]?</p>