LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 01-15-2006, 05:28 AM   #1
dormant
LQ Newbie
 
Registered: May 2003
Posts: 18

Rep: Reputation: 0
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.
 
Old 01-15-2006, 06:24 AM   #2
berbae
Member
 
Registered: Jul 2005
Location: France
Distribution: Arch Linux
Posts: 540

Rep: Reputation: Disabled
Hello dormant
try that
find /here/there -type f -exec dirname {} \; |sort|uniq
 
Old 01-15-2006, 06:53 AM   #3
dormant
LQ Newbie
 
Registered: May 2003
Posts: 18

Original Poster
Rep: Reputation: 0
Thanks berbae,

I never cease to be amazed by the ingenuity of serious Linux users. One day, that'll be me.
 
Old 01-15-2006, 08:53 AM   #4
berbae
Member
 
Registered: Jul 2005
Location: France
Distribution: Arch Linux
Posts: 540

Rep: Reputation: Disabled
You are welcome but it's too much praise
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 08:42 AM
Several "find -exec" and "find | xargs" questions thanhvn Programming 4 12-02-2005 02:04 PM
"bottom half" vs "softirq" kpachopoulos Programming 1 10-28-2005 08:00 AM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 03:32 PM
strange group and user set to "573" in linux-2.4.27 tree structure xround Linux - General 2 10-12-2004 12:09 PM


All times are GMT -5. The time now is 10:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration