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. |
Hello dormant
try that find /here/there -type f -exec dirname {} \; |sort|uniq |
Thanks berbae,
I never cease to be amazed by the ingenuity of serious Linux users. One day, that'll be me. |
You are welcome but it's too much praise :D
|
All times are GMT -5. The time now is 03:20 PM. |