gunbol
August 8, 2005, 9:19am
1
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.
I am trying to find out a script to make my work easier... I'm affraid i should do it by myself.
I someone could help me, it would be very nice ;o)
Gunther
find $PARENT_DIR -type DIR -print
aigles
August 8, 2005, 11:12am
3
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
$
Ygor
August 8, 2005, 10:13pm
4
Handy one liner...
find . -type d -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
that is very helpful/cool!
thanks for posting it!