Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-07-2010, 09:31 AM   #1
Senior Member
Registered: Jun 2009
Posts: 1,795

Rep: Reputation: 49
How to delete all empty folders

I just had a bad experience with a server, and now i have a 17GB lost+found. It appears a lot of the stuff in there are folders which are empty. Since those really serve no purpose as far as recovering data from what I can tell, is there a slick way to delete just the empty folders from my /data/lost+found folder, leaving me with just the stuff I truly need to look through?
Old 06-07-2010, 09:44 AM   #2
Registered: Jun 2010
Location: France
Distribution: openSUSE 11.2, (B)LFS, Mepis, Linux Mint 9
Posts: 30

Rep: Reputation: 17
Hello rjo98,

Not sure I well understood you question, anyway, you may do :

 rm -fr /data/lost+found
WARNING : this will remove everything (folders & files) into 'lost+found' and the 'lost+found' folder itself.

What about removing only the empty folders :

find 'yourbasedir_name' -depth -empty -type d -exec rmdir {} \;
That gives :

 find /data/lost+found -depth -empty -type d -exec rmdir {} \;
or under /data/lost+found :

 cd /data/lost+found
find * -depth -empty -type d -exec rmdir {} \;
Hope it helped..


Last edited by g33ky; 06-07-2010 at 09:50 AM.
Old 06-07-2010, 09:47 AM   #3
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

Rep: Reputation: 92
Try this:

# find -depth -type d -empty -exec rmdir {} \;
Run from within the directory that contains the empty sub-directories you want to delete.
Old 06-07-2010, 12:01 PM   #4
Senior Member
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Thanks to you both, looks like you both came to the same conclusion!


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
find -exec command to recursively delete files and folders in folders with X name Joan Murt Linux - Newbie 2 07-08-2009 05:35 PM
clear empty folders of client computers by linux maryam.sf Linux - Server 5 05-06-2009 12:36 PM
Kubuntu creates empty folders in my home dir bhert Ubuntu 3 06-26-2008 01:59 PM
Samba shares show empty folders Venefyxatu Linux - Wireless Networking 8 06-18-2008 02:50 AM
pkgtool and empty folders jstef Slackware 2 02-04-2003 10:06 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:23 PM.

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