Tree with UNIX

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Tree with UNIX
# 1  
Old 08-08-2005
Lightbulb 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.


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

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

# 2  
Old 08-08-2005

find $PARENT_DIR -type DIR -print
# 3  
Old 08-08-2005
A solution using find and sed :

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

# tree.sed

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


# Elimine la racine mémorisée


# Formatte

s+[^/]*/+|  +g

# End of script


$ tree AIX.TOOLS

|  L__lpp
|  |
|  L__local
|  |  L__bin
|  |  L__lib
|  |  |  L__tools
|  |  |  L__pstree-2.6
|  |  L__man
|  |  |  L__man1
|  L__bin


# 4  
Old 08-09-2005
Handy one liner...
find . -type d -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'

# 5  
Old 08-09-2005
Originally Posted by Ygor
Handy one liner...
find . -type d -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'

Smilie impressive-d.

sorry just had to say Smilie
# 6  
Old 04-09-2008
that is very helpful/cool!

thanks for posting it!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Binary Tree

I have just been researching this topic and I was wondering what type of application might a binary tree be used for. For instance what type of application would be a good showcase for a binary tree that I could write as an example? (5 Replies)
Discussion started by: sepoto
5 Replies

2. UNIX for Dummies Questions & Answers

Tree command

How can i install tree command in ubundu without root ? I have found some shell script which does the same job as tree but i would like to get all the options in tree command thanks (2 Replies)
Discussion started by: gvj
2 Replies

3. UNIX for Dummies Questions & Answers

How to create this tree?

a buddy and i are trying to re-learn basic commands. i havent used linux for awhile. so i need help on this. what are the commands to create a tree like this. . |-- a1.A |-- a1.B |-- opt | |-- documents | | `-- tmp | | |-- backup | | `-- etc | |-- music | `--... (1 Reply)
Discussion started by: ink
1 Replies

4. Shell Programming and Scripting

process tree

how to draw a process tree if i know my process id and how can i identify session leaders (1 Reply)
Discussion started by: annapurna konga
1 Replies

5. UNIX for Dummies Questions & Answers

Tree directory structure of Unix to get final node path

Hi, I want to list all the last directories from mentioned base path. for eg: If i have a base path say /base/base1/ How can i get the path till last node in tree like directory structure of unix by applying any command. so that i will get following output. ... (7 Replies)
Discussion started by: Shiv@jad
7 Replies

6. Shell Programming and Scripting

directory tree

Hi all, The following is a script for displaying directory tree. D=${1:-`pwd`} (cd $D; pwd) find $D -type d -print | sort | sed -e "s,^$D,,"\ -e "/^$/d"\ -e "s,*/\(*\)$,\:-----\1,"\ -e "s,*/,: ,g" | more exit 0 I am trying to understand the above script.But... (3 Replies)
Discussion started by: ravi raj kumar
3 Replies

7. UNIX for Dummies Questions & Answers

tree command

In DOS, to get the complete directory structure, we use 'TREE' command.. can anyone tell me what is the equivalent command in Unix I am using SunOS ABC 5.8 Generic_117350-18 sun4u sparc SUNW,Sun-Fire-V240 thanks.. (1 Reply)
Discussion started by: wip_vasikaran
1 Replies

8. Programming

directory as tree

hi i have modified a program to display directory entries recursively in a tree like form i need an output with the following guidelines: the prog displays the contents of the directory the directory contents are sorted before printing so that directories come before regular files if an entry... (2 Replies)
Discussion started by: anything2
2 Replies

9. Shell Programming and Scripting

· simerian · UNIX Process List Tree

#!/usr/bin/ksh # # COPYRIGHT (c) 2003 - SIMERIAN # # e: # w: # # DISCLAIMER # The author of this product does not accept any responsibility for # loss or damages resulting from the use of said product and makes no # warranty or representation, either... (3 Replies)
Discussion started by: Simerian
3 Replies

10. Programming

making a process tree

How can I make a process tree? The tree must have X rows and each process must have Y sons. All the processes must comunicate with their fathers. Can anyone help me with that? (1 Reply)
Discussion started by: bb666
1 Replies
Login or Register to Ask a Question

Featured Tech Videos