Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Display unix directory hierarchy

RE: Display unix directory hierarchy

From: <Stephen.Lee_at_DTAG.Com>
Date: Fri, 26 Dec 2003 07:59:25 -0800
Message-ID: <F001.005DB19E.20031226075925@fatcity.com>

It suddenly popped into my head a couple days ago that there could be a problem with the script (isn't it crazy what the subconscious mind does?). Note that when it cd's to a new directory, it ASS-U-MEs that it can do that; and then it calls the script again. I haven't verified if for sure (shoot me now), but I think this could set up a nasty loop. So one should test the readability and executability (??) of the directory before trying to cd into it -- the solution to which is left as an exercise for the reader. (AAAUGH! Yeah, I've had a Math course or two.)

> -----Original Message-----
>
> 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.
>
> ------------------------------------------
> #!/bin/ksh
>
> 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 ..
> }
> fi
> done
> ------------------------------------
> --
> 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).
>

-- 
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 Fri Dec 26 2003 - 09:59:25 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US