title: bash: put list files into a variable and but size of array is 1
body: <p>I am listing the files in a directory and looping through them okay, BUT I need to know how many there are too. ${#dirlist[@]} is always 1, but for loop works?</p>
  
  <pre><code>#!/bin/bash
  prefix="xxx"; # as example
  
  len=${#prefix}; # string length
  dirlist=`ls ${prefix}*.text`;
  qty=${#dirlist[@]};  # sizeof array is always 1
  for filelist in $dirlist
  do
      substring="${filelist:$len:-5}";
      echo "${substring}/${qty}";
  done
  </code></pre>
  
  <p>I have files xxx001.text upto xxx013.text<br>
  but all I get is 001/1  002/1  003/1</p>