LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 04:28 AM   #1
dormant
LQ Newbie
 
Registered: May 2003
Posts: 19

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, 05: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, 05:53 AM   #3
dormant
LQ Newbie
 
Registered: May 2003
Posts: 19

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, 07: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



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 07:42 AM
Several "find -exec" and "find | xargs" questions thanhvn Programming 4 12-02-2005 01:04 PM
"bottom half" vs "softirq" kpachopoulos Programming 1 10-28-2005 07:00 AM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 02:32 PM
strange group and user set to "573" in linux-2.4.27 tree structure xround Linux - General 2 10-12-2004 11:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:26 PM.

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
Open Source Consulting | Domain Registration