LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How can I find the "bottom" directories in a tree (https://www.linuxquestions.org/questions/linux-software-2/how-can-i-find-the-bottom-directories-in-a-tree-403539/)

dormant 01-15-2006 04:28 AM

How can I find the "bottom" directories in a tree
 
I need a way of finding all the "bottom" directories in a directory tree.

I want to tidy up file names in a big directory tree using detox (detox.sourceforge.net). It has a recursive option, but this means it will tidy up the directory names as well. I don't want to change the directory names, I like them, I just want to tidy the file names.

So I need to be able to pass the names of the directories I want to detox. This means I want to get only the "bottom" directories - those directories that contain only files, not directories.

ls seems to be useless for the job. The -R option doesn't work with the -d option.

find /here/there -type d lists ALL directories.

I was about to write a Perl script to do this, but it seems an over-complicated approach. There must be an easier way.

Any suggestions?

In case it matters, I am using Fedora Core 4.

berbae 01-15-2006 05:24 AM

Hello dormant
try that
find /here/there -type f -exec dirname {} \; |sort|uniq

dormant 01-15-2006 05:53 AM

Thanks berbae,

I never cease to be amazed by the ingenuity of serious Linux users. One day, that'll be me.

berbae 01-15-2006 07:53 AM

You are welcome but it's too much praise :D


All times are GMT -5. The time now is 03:20 PM.