title: Convert multiline string to array
body: <p>I have this script:</p>
  <pre><code>nmapout=`sudo nmap -sP 10.0.0.0/24`
  names=`echo &quot;$nmapout&quot; | grep &quot;MAC&quot; | grep -o '(.\+)'`
  echo &quot;$names&quot;
  </code></pre>
  <p>now the <code>$names</code> variable contains strings delimited with newlines:</p>
  <pre><code>&gt;_
   (Netgear)
   (Hon Hai Precision Ind. Co.)
   (Apple)
  </code></pre>
  <p>I tried to do the array conversion with the sub-string approach:</p>
  <pre><code>names=(${names//\\n/ })
  echo &quot;${names[@]}&quot;
  </code></pre>
  <p>But the problem is that I can't access them by indexing (i.e., <code>${names[$i]</code> etc.), if I run this loop</p>
  <pre><code>for (( i=0; i&lt;${#names[@]}; i++ ))
  do
       echo &quot;$i: ${names[$i]&quot;
       # do some processing with ${names[$i]}
  done
  </code></pre>
  <p>I get this output:</p>
  <pre><code>&gt;_
   0: (Netgear)
   1: (Hon
   2: Hai
  </code></pre>
  <p>but what I want is:</p>
  <pre><code>&gt;_
   0: (Netgear)
   1: (Hon Hai Precision Ind. Co.)
   2: (Apple)
  </code></pre>
  <p>I could not figure out a good way to do this, please note that the second string has spaces in it.</p>