Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Display unix directory hierarchy
In addition to the fine solution from Bambi, Here's another approach that I think will work. I did only minimal testing (in TRUE development tradition. But ... But ... It worked OK in test!). One caveat: This relies on recursion, so on a big directory tree you might get swatted with OS resource limitations.
if [ $# -eq 1 ]; then
ARG=$1
else
ARG=0
export MYNAME="`pwd`/`basename $0`"
fi
X=0
PAD=""
while [ $X -lt $ARG ]; do
PAD=$PAD" "
X=$(( X + 1 ))
done
## list non-directory files first
for i in `ls -a1 2> /dev/null`; do
if [ "$i" = "." -o "$i" = ".." ]; then
continue
fi
if [ ! -d $i ]; then
echo "$PAD$i"
fi
done
## then plow into the directories
## NO. They ain't "folders". They're "DIRECTORIES".
for i in `ls -a1 2> /dev/null`; do
if [ "$i" = "." -o "$i" = ".." ]; then
continue
fi
if [ -d "$i" ]; then
echo "$PAD/$i" { cd "$i" $MYNAME $(( $ARG + 1 )) cd .. }
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: <Stephen.Lee_at_DTAG.Com INET: Stephen.Lee_at_DTAG.Com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Tue Dec 23 2003 - 14:09:32 CST