traverse() 
{
  # Traverse a directory
  cd "$1"

  ls | while read i
  do
    if [ -d "$i" ]
    then
      echo "Directory: $i"
      # Calling this as a subshell means that when the called
      # function changes directory, it will not affect our
      # current working directory
      (traverse "$i" `expr $2 + 1`)
    else 
      echo "File: $i"
      gunzip $i
      rm $i
    fi
  done
}

if [ -z "$1" ]
then
  traverse . 0
else
  traverse "$1" 0
fi
