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

For example, how do I print all directories/sub directories under /etc or /var .. (include directory that start with dot ".")?

Example of printing

find <some path> -type d
  • 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
  • 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

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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