Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to print the full path of directories and all sub directories under some source directory

for example

how to print all directories/sub directories under /etc or /var .. (include directory that start with dot ".")

Jennifer

example of printing

/etc/rc0.d
/etc/rc1.d
/etc/rc2.d
/etc/rc3.d
/etc/rc4.d
/etc/rc5.d
/etc/rc6.d
/etc/.test.dir
/etc/xd1/menus/preferences-merged
/etc/xd2/menus/applications-merged
/etc/xd3/menus/preferences-post-merged
.
.
.
.
share|improve this question

2 Answers 2

up vote 2 down vote accepted
find <some path> -type d
share|improve this answer
    
hi I have littlie problem if for example /var -> /var/newdir/dir then find command cant find the subdirectories (because /var is linked to /var/newdir/dir –  jennifer Oct 3 '10 at 11:46
    
/var -> /var/newdir/dir seems to me a quite strange linkage, but you should use -L option to make find follows symbolic links. –  cYrus Oct 3 '10 at 11:57
    
my linux not support the -L option so I write: find /var -type l -type d (something wrong with this ?) –  jennifer Oct 3 '10 at 14:05
    
@jennifer: You can add a slash at the end of the argument to make find follow a symbolic link on the starting path, e.g., find /var/ -type d. –  Gilles Oct 3 '10 at 20:56
    
@jennifer to do symlinks, find has the -follow flag. find /var -follow -type d –  Rich Homolka Oct 4 '10 at 15:39

tree will do it. To include '.dotfiles' -a, to show full path for each file -f:

tree -af

and if you do not like indentation:

tree -afi
share|improve this answer
1  
find has the advantage that it's always installed whereas tree needs to be installed manually on most distributions. –  lajuette Oct 3 '10 at 11:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.