directory tree

Hi all,
The following is a script for displaying directory tree.

D=${1:-`pwd`}
(cd $D; pwd)
find $D -type d -print | sort |
sed -e "s,^$D,,"\
-e "/^$/d"\
-e "s,[^/]*/\([^/]\)$,\:-----\1,"\
-e "s,[^/]
/,: ,g" | more
exit 0

I am trying to understand the above script.But i am not able to understand the following 2 lines

-e "s,[^/]*/\([^/]\)$,\:-----\1,"\
-e "s,[^/]
/,: ,g" | more

can any body pls tell me how the above two lines works.

cheers
RRK

these are sed syntex of find and replace...with regular expressions..
in first line- its searching for "/" in the begining of line for any occurance of "/". [ shown by "*"] escaped paranthesis are used to tell how many occurance.. $ used to find @ the end of every line.. \1,\2 etc used to tell where to find...

1 more thing.. [^/] means not to find "/". "^" is used to tell in the start of the line...
and if "^" used inside [] thn it treats as the negation of the exression followed by "^".

hope its clear.

I did an awk tree sometime ago, maybe could be usefull for you:

find . -type d -print 2>/dev/null|awk '!/\.$/ {for (i=1;i<NF;i++){d=length($i);if ( d < 5  && i != 1 )d=5;printf("%"d"s","|")}print "---"$NF}'  FS='/'