title: How can I count the hidden files in a directory using a shell script?
body: <p>I have used this code  </p>
  
  <pre><code>#!/bin/bash
  
  ls -l
  echo -n "Number of simple files : "
  ls -l | egrep '^-' | wc -l 
  echo -n "Number of directories : "
  ls -l | egrep '^d' | wc -l
  echo -n "Number of hidden files : "
  ls -la | egrep '^.*\.$' | wc -l
  echo -n "Number of hidden directories : "
  ls -la | egrep '^d.*\.$' | wc -l
  echo " End"
  </code></pre>
  
  <p>While I can understand how the first two egrep work I can't figure out how the last
  two work. More specific what does this mean <code>'^.*\.$'</code> ?
  I want a file that starts with . (hidden file) and then how I should shape my regular expression?</p>