RE: Display unix directory hierarchy

2003-12-26 Thread Stephen.Lee

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: [EMAIL PROTECTED]
   INET: [EMAIL PROTECTED]
 
 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: [EMAIL PROTECTED] (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: [EMAIL PROTECTED]
  INET: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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).


RE: Display unix directory hierarchy

2003-12-23 Thread Mark Leith
Hi Barb,

You can use tree/dtree to do this. Windows also has a tree dos command
to do the same. 

HTH

Mark


-Original Message-
Barbara Baker
Sent: 23 December 2003 08:49
To: Multiple recipients of list ORACLE-L


Hi, listers.
As documentation for a project, I would like to
display some unix directories in hierarchical format
and add the output to the documentation set.
(Solaris 9)

Either flowchart-like or explorer-like will do.  Sorta
like what is shown below.  Does anyone know of a
freebie tool that will do this?  (Or is this some
fancy ls command I'm missing?)

Thanks for any help.
Barb


/dna
  /orasrv
 /1.4
/scripts
 /1.7
/scripts
  /logs


__
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Barbara Baker
  INET: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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).

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.537 / Virus Database: 332 - Release Date: 06/11/2003
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.537 / Virus Database: 332 - Release Date: 06/11/2003
 

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Mark Leith
  INET: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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).


RE: Display unix directory hierarchy

2003-12-23 Thread Seibert, Jason
Barbara,

You might try tossing the following snippet in a shell script. I call it
dtree and you can pass a parameter of a directory.
=== snip
 D=${1:-`pwd`}
 (cd $D; pwd)
 find $D -type d -print | sort |
 sed -e s,^$D,,\
 -e /^$/d\
 -e s,[^/]*/\([^/]*\)$,\:-\1,\
 -e s,[^/]*/,: ,g

== snip

... Output looks like 
:-somedir1
: :-somedir2
: :-somedir3
: :-somedir4
:-somedir2
:-somedir3
:-somedir4
: :-somedir1
: : :-somedir2
: : :-somedir3
: : :-somedir4
: :-somedir2
: :-somedir3

-Original Message-
Sent: Tuesday, December 23, 2003 9:49 AM
To: Multiple recipients of list ORACLE-L


Hi, listers.
As documentation for a project, I would like to
display some unix directories in hierarchical format
and add the output to the documentation set.
(Solaris 9)

Either flowchart-like or explorer-like will do.  Sorta
like what is shown below.  Does anyone know of a
freebie tool that will do this?  (Or is this some
fancy ls command I'm missing?)

Thanks for any help.
Barb


/dna
  /orasrv
 /1.4
/scripts
 /1.7
/scripts
  /logs


__
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Barbara Baker
  INET: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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: Seibert, Jason
  INET: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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).


RE: Display unix directory hierarchy

2003-12-23 Thread Bellow, Bambi
Here's a freebie...

Bambi.
=
#!/bin/ksh
LEVEL=1
INCREMENT=FALSE
ls -lR|grep -v ^total|while read i
do

echo $i|grep ^d /dev/null 2/dev/null
if [ $? -eq 0 ] ;
then
continue
fi
FILE=`echo $i|awk '{print $NF}'`

echo $i|grep \/ /dev/null 2/dev/null
if [ $? -eq 0 ] ;
then
LEVEL=`expr \`echo $i|awk -F/ '{print NF}'\` - 1`
FILE=`echo $i|awk -F/ '{print / $NF}'|sed s/://`
INCREMENT=TRUE
fi

CTR=1
while [ $CTR -lt $LEVEL ] ;
do
echo   \c
let CTR=CTR+1
done
echo $FILE
if [ $INCREMENT = TRUE ] ;
then
let LEVEL=LEVEL+1
INCREMENT=FALSE
fi
done|pg
==

-Original Message-
Sent: Tuesday, December 23, 2003 10:49 AM
To: Multiple recipients of list ORACLE-L


Hi, listers.
As documentation for a project, I would like to
display some unix directories in hierarchical format
and add the output to the documentation set.
(Solaris 9)

Either flowchart-like or explorer-like will do.  Sorta
like what is shown below.  Does anyone know of a
freebie tool that will do this?  (Or is this some
fancy ls command I'm missing?)

Thanks for any help.
Barb


/dna
  /orasrv
 /1.4
/scripts
 /1.7
/scripts
  /logs


__
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Barbara Baker
  INET: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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: Bellow, Bambi
  INET: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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).


RE: Display unix directory hierarchy

2003-12-23 Thread Stephen.Lee

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: [EMAIL PROTECTED]
  INET: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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).