#!/bin/ksh # # Name: dirtree # Programmer: # Hemant T. Shah # Life Insurance Data Processing # July 12 1994 # # Description: # Print directory tree structure as follows: # !./ # |___.3270keys # |___.Xauthority # |___.Xdefaults # |___.elm/ # ! |___aliases.text # |___.gdbinit # |___.reminders/ # ! |___cron.entry # ! |___everyday # ! |___friday # ! |___monday # ! |___send_reminders_to # ! |___thursday # ! |___tuesday # ! |___wednesday # |___.rgy_editrc # |___cob/ # ! |___dbcob/ # ! ! |___ac/ # ! ! ! |___t/ # ! |___errcob/ # ! ! |___APADMI00 # ! ! |___tmp # ! |___gblcob/ # ! ! |___ac/ # ! ! ! |___p/ # ! ! ! |___t/ # ! ! |___ap/ # ! ! ! |___a/ # ! ! ! |___m/ # ! ! ! ! |___APMEP100 # ! ! |___dfh/ # # ProgramName=${0##*/} Path="." ShowAll=1 ShowDir=0 ExpandDirectory() { typeset object # Local variable cd $1 for object in $PWD/.??* $PWD/* do if [[ -d $object ]]; # It is a directory then print "${indent}|___`basename ${object}`/" indent="${indent}! " # Add to indentation if [[ -x $object ]]; then ExpandDirectory $object fi indent=${indent%???} # Remove frm indentation elif [[ -f $object ]]; # It is a file then if (( ShowAll == 1 )); then print "${indent}|___`basename ${object}`" fi fi done } if [[ $# > 0 ]]; then while [ $# -gt 0 ]; do case $1 in -f) ShowAll=1 shift ;; -d) ShowDir=1 ShowAll=0 shift ;; -*) print "Usage: $ProgramName [-f] [-d] [path] " print -- "\t-f path ... shows all files and directories below \ path (default)." print -- "\t-d path ... shows all directories only below path." exit ;; *) Path=$1 shift ;; esac done fi if [[ ! -d $Path ]]; then print "Error: Specified path is not a directory." exit fi print "!$Path" ExpandDirectory $Path