Tree with UNIX

Hello !

I am trying to find out if a simple command could build me a tree containing all the subdirectories for a specific directory.

I have a tree like /home/user/blabla..../mytree with a lot of symbolic links. It is quite tricky to find out where my data are 'logically' stored.

:confused:

I am trying to find out a script to make my work easier... I'm affraid i should do it by myself. :frowning:

I someone could help me, it would be very nice ;o)

Gunther

find $PARENT_DIR -type DIR -print

A solution using find and sed :

# tree
echo
find "${1:-.}" -type d | sed -f tree.sed
echo
# tree.sed

#
# M�morise la racine avec / en fin
# et l'affiche sans
#

1{
s+/$++;
h
s+[^/]$+&/+
x
b
}

#
# Elimine la racine m�moris�e
#

H
g
s+\(.*\)\n.*+\1+
x
s+\(.*\)\n\1++

#
# Formatte
#

s+[^/]*$+L__&+
s+[^/]*/+|  +g

# End of script

example:

$ tree AIX.TOOLS

AIX.TOOLS
L__usr
|  L__lpp
|  |  L__freeware.aix.tools
|  L__local
|  |  L__bin
|  |  L__lib
|  |  |  L__tools
|  |  |  L__pstree-2.6
|  |  L__man
|  |  |  L__man1
|  L__bin

$

Handy one liner...

find . -type d -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'

:slight_smile: impressive-d.

sorry just had to say :slight_smile:

that is very helpful/cool!

thanks for posting it!