Echo expression in bash
<p>I have been trying to print maximal depth of directory but I can't figure out how to print the results in the format "Maximal depth: xxx" </p>

<pre><code>    dir_depth() {
      cd "$1"
      maxdepth=0
      for d in */.; do
        [ -d "$d" ] || continue
        depth=`dir_depth "$d"`
        maxdepth=$(($depth &gt; $maxdepth ? $depth : $maxdepth))
      done
      echo $((1 + $maxdepth)) #this line is problem
    }

dir_depth "$@"
</code></pre>

<p>If I try to do it like </p>

<pre><code>    foo=$((1 + $maxdepth))
    echo "Maximal depth: " $foo
</code></pre>

<p>then I get an error</p>

<pre><code>Max depth: 1: expression recursion level exceeded (error token is "depth: 1")
</code></pre>