Added gitignore entries needed to ignore derived objects generated from full build...
[bash.git] / examples / scripts / vtree3a
blob0678764b26753eae2075005418eeeb0774c8934c
1 #!/bin/bash
3 # Name: dirtree
4 # Programmer:
5 # Hemant T. Shah
6 # Life Insurance Data Processing
7 # July 12 1994
9 # Description:
10 # Print directory tree structure as follows:
11 # |___Mail
12 # |___scheduler
13 # |___cics_scripts
14 # |___tar_msdos
15 # |___awk
16 # |___attributes
17 # |___tmp
18 # |___News
19 # |___dosscsi
20 # |___FAQ_xterminal
21 # |___shell_history.Z
22 # |___FAQ_AIX
23 # |___aix_ftp_site
24 # |___hp_software
25 # |___dnload
26 # |___telnet.h
27 # |___msdos
28 # |___tnetd.tar.Z
29 # |___aix
30 # |___hp
31 # |___xkey.c
33 # Conversion to bash v2 syntax done by Chet Ramey
34 # - removed command substitutions calling `basename'
37 ProgramName=${0##*/}
38 Path="."
39 ShowAll=1
40 ShowDir=0
43 ExpandDirectory()
45 local object # Local variable
47 cd "$1"
49 for object in $PWD/.??* $PWD/*
51 if [ -d $object ]; # It is a directory
52 then
53 echo "${indent}|___${object##*/}/"
54 indent="${indent}! " # Add to indentation
55 if [ -x $object ];
56 then
57 ExpandDirectory $object
59 indent=${indent%????} # Remove from indentation
60 elif [ -e $object ]; then
61 if (( ShowAll == 1 ));
62 then
63 echo "${indent}|___${object##*/}"
66 done
70 usage()
72 echo -e "Usage: $ProgramName [-h] [-f] [-d] [path] "
73 echo -e "\t-h ... display this help message."
74 echo -e "\t-f path ... shows all files and directories below path (default)."
75 echo -e "\t-d path ... shows all directories only below path."
78 while getopts "fd" opt
80 case $opt in
81 f) ShowAll=1 ;;
82 #d) ShowDir=1 ;;
83 d) ShowAll=0 ;;
84 *) usage ; exit 2;;
85 esac
86 done
88 shift $(( $OPTIND - 1 ))
90 Path=${1:-.}
92 if [ ! -d "$Path" ]; then
93 echo "$0: error: specified path is not a directory." >&2
94 exit 1
99 echo "!$Path/"
100 ExpandDirectory $Path