![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to find empty folders without using -empty | lasse | UNIX for Dummies Questions & Answers | 7 | 01-16-2008 11:30 PM |
| identify the empty directories | mohan705 | Shell Programming and Scripting | 5 | 07-07-2007 08:31 AM |
| Empty directories having different size | rahulrathod | UNIX for Dummies Questions & Answers | 3 | 01-19-2006 08:53 AM |
| Help identifying empty directories | dboard | UNIX for Dummies Questions & Answers | 2 | 11-09-2005 12:07 PM |
| searching for list of empty directories | man80 | Shell Programming and Scripting | 4 | 10-15-2004 01:00 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
scanning empty directories
Hi,
I want to produce a text file representing a list of empty directories on a unix system starting from a specified directory. I hope I explained well my problem. Thanks in advance. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
If you're just looking to delete empty directories, you can use this:
Code:
find . -exec rmdir {} \;
As far as just creating a list, I'm not sure... |
|
#3
|
|||
|
|||
|
Quote:
use -print after the semicolon so you can see a list of the directories you just deleted. |
|
#4
|
||||
|
||||
|
Figured out a better way.
Code:
find . -type d -links 2 -exec echo '{}' >> somefile \;
|
|
#5
|
|||
|
|||
|
Hi Oombera,
thanks for your suggestion. However, it doesn't seem to work 100%. it returns all the directories, empty or not. I must say, I tried your command on a Iseries (AS400) UNIX shell. I will try it on a real UNIX (sun solaris) machine. I'll keep you in touch. PS. with you it worked well? Thanks |
|
#6
|
||||
|
||||
|
Quote:
|
|
#7
|
|||
|
|||
|
as400 is more mainframe then it is a unix.
as400 commands are really weird, iv only had a brief experiance with as400 when i used to tool around on it when i worked for a school. it wouldnt surpise me that the find command didnt perform as expected on an as400. oombera your orig command would work. i am haveing a hard time understanding what the use of the -links 2 is for in this instance. unless a file has 2 links to it it will not be posted. find . -type d -exec rmdir {} \; -print this is what you would be looking for. |
|||
| Google The UNIX and Linux Forums |