#!/bin/bash ########################################### # # A script to list all subdirectories of a # directory along with their number # Usage: list_subdirs [directory] # # Author: Bill Kraynek # Created on February 27th, 2007 # ########################################## if [ $# = 0 ]; then dir="." elif [ $# = 1 ]; then dir=$1 else echo "Usage: $0 [directory name]" exit 1 fi echo "Directory is $dir" ls $dir > lsout x=0 while read file; do file1="$dir"/"$file" if [ -d "$file1" ]; then echo "$file is a subdirectory" let x=$x+1 fi done < lsout echo "The number of subdirectories is $x."