title: How to count number of files and subdirectories with shellscript?
body: <p>Current code:</p>
  
  <pre><code>echo "What absolute directory do you want to count?"
  read DIR
  cd $DIR
  files=`ls`
  file=0;
  dir=0;
  for d in $files
  do
      dir=`expr $dir + 1`
  done
  for f in $files
  do
      file=`expr $file + 1`
  done
  echo "Files $file"
  echo "Directories $dir"
  </code></pre>
  
  <p>The proper output should be (based on the folder I measure):</p>
  
  <pre><code>Files: 20
  Directories: 1
  </code></pre>
  
  <p>But I'm getting:</p>
  
  <pre><code>Files: 22
  Directories: 22
  </code></pre>
  
  <p>So it's count files and subdirectories together, I want them to be separate. Any ideas? Thanks.</p>