<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Linux how do I remove all empty directories?</title> <atom:link href="http://www.cyberciti.biz/faq/linux-how-do-i-remove-all-empty-directories/feed/" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/faq/linux-how-do-i-remove-all-empty-directories/</link> <description>Every answer asks a more beautiful question.</description> <lastBuildDate>Fri, 10 Feb 2012 19:55:56 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Scott</title><link>http://www.cyberciti.biz/faq/linux-how-do-i-remove-all-empty-directories/#comment-39353</link> <dc:creator>Scott</dc:creator> <pubDate>Wed, 03 Dec 2008 03:30:24 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/linux-how-do-i-remove-all-empty-directories.php#comment-39353</guid> <description>Try:
for v in targetdir/*; do [ $(ls -lA $v &#124; wc -l) -eq 1 ] &amp;&amp; rmdir $v; done;
-A (almost all) option to ls reports hidden files (without . and .. entries). The for loop removes all empty directories.</description> <content:encoded><![CDATA[<p>Try:</p><p>for v in targetdir/*; do [ $(ls -lA $v | wc -l) -eq 1 ] &amp;&amp; rmdir $v; done;</p><p>-A (almost all) option to ls reports hidden files (without . and .. entries). The for loop removes all empty directories.</p> ]]></content:encoded> </item> <item><title>By: Frolic</title><link>http://www.cyberciti.biz/faq/linux-how-do-i-remove-all-empty-directories/#comment-38081</link> <dc:creator>Frolic</dc:creator> <pubDate>Wed, 11 Jun 2008 13:48:57 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/linux-how-do-i-remove-all-empty-directories.php#comment-38081</guid> <description>&lt;code&gt;find . -type d -empty &#124; xargs rmdir&lt;/code&gt;
can be faster than using &lt;code&gt;-exec&lt;/code&gt; if you find a large number of directories. To be safe if your directory names contain spaces or other characters that act as word separators:
&lt;code&gt;find . -type d -empty -print0 &#124; xargs -0 rmdir&lt;/code&gt;
The circular things are the digit zero, not the capital letter Oh. The &lt;code&gt;-delete&lt;/code&gt; action mentioned above by Lingerance seems to be a nonstandard extension - GNU find doesn&#039;t know about it.</description> <content:encoded><![CDATA[<p><code>find . -type d -empty | xargs rmdir</code><br
/> can be faster than using <code>-exec</code> if you find a large number of directories. To be safe if your directory names contain spaces or other characters that act as word separators:<br
/> <code>find . -type d -empty -print0 | xargs -0 rmdir</code><br
/> The circular things are the digit zero, not the capital letter Oh. The <code>-delete</code> action mentioned above by Lingerance seems to be a nonstandard extension &#8211; GNU find doesn&#8217;t know about it.</p> ]]></content:encoded> </item> <item><title>By: Lingerance</title><link>http://www.cyberciti.biz/faq/linux-how-do-i-remove-all-empty-directories/#comment-36838</link> <dc:creator>Lingerance</dc:creator> <pubDate>Tue, 18 Sep 2007 07:59:51 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/linux-how-do-i-remove-all-empty-directories.php#comment-36838</guid> <description>find . -type d -empty -delete</description> <content:encoded><![CDATA[<p>find . -type d -empty -delete</p> ]]></content:encoded> </item> <item><title>By: don</title><link>http://www.cyberciti.biz/faq/linux-how-do-i-remove-all-empty-directories/#comment-8993</link> <dc:creator>don</dc:creator> <pubDate>Fri, 02 Feb 2007 01:34:29 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/linux-how-do-i-remove-all-empty-directories.php#comment-8993</guid> <description>perl -MFile::Find -e &quot;finddepth(sub{rmdir},&#039;.&#039;)&quot;
or
find -depth -type d -empty -exec rmdir {} \;
is easier</description> <content:encoded><![CDATA[<p>perl -MFile::Find -e &#8220;finddepth(sub{rmdir},&#8217;.')&#8221;</p><p>or</p><p>find -depth -type d -empty -exec rmdir {} \;</p><p>is easier</p> ]]></content:encoded> </item> </channel> </rss>
