title: Shell script recursion doesnt work
body: <p>I have a shell script to count all my files and directories sizes using recursive function
  Here's my code:</p>
  
  <pre><code>#!/bin/bash
  count() {
    local file
    total=$2
    files=(`ls $1`)
    for file in "$files"
    do
      if [ -d "$1/$file" ]
      then
        count "$1/$file" $total
      else
        #size=`du $file | grep -o [0-9]*`
        #total=$(($2 + $size))
        echo "$1/$file"
      fi
    done
  }
  total=0
  count . $total
  echo "$total"
  </code></pre>
  
  <p>I have error somewhere it just goes into the first directory prints the file and stops. Where's my error? :)</p>