<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Into.the.Void. &#187; xargs</title>
	<atom:link href="http://www.void.gr/kargig/blog/tag/xargs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.void.gr/kargig/blog</link>
	<description>Into The Void</description>
	<lastBuildDate>Sat, 07 Aug 2010 08:06:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>delete all empty directories using xargs</title>
		<link>http://www.void.gr/kargig/blog/2009/04/16/delete-all-empty-directories-using-xarg/</link>
		<comments>http://www.void.gr/kargig/blog/2009/04/16/delete-all-empty-directories-using-xarg/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 17:50:41 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[xargs]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=453</guid>
		<description><![CDATA[I was trying to figure out one 1-liner to delete all empty directories in a tree.
The following should do it&#8217;s job:
%find -type d -empty &#124; xargs rm -rvf
BUT! While this works for directories with &#8220;regular&#8221; filenames, it doesn&#8217;t work when there are special characters inside the filename. Consider this for example:
%ls -1
test 1
test2
test _ 3
%find [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to figure out one 1-liner to delete all empty directories in a tree.<br />
The following should do it&#8217;s job:<br />
<code>%find -type d -empty | xargs rm -rvf</code></p>
<p>BUT! While this works for directories with &#8220;regular&#8221; filenames, it doesn&#8217;t work when there are special characters inside the filename. Consider this for example:</p>
<p><code>%ls -1<br />
test 1<br />
test2<br />
test _ 3<br />
%find -type d -empty<br />
./test 1<br />
./test2<br />
./test _ 3<br />
%find -type d -empty | xargs rm -rvf<br />
removed directory: `./test2'<br />
%find -type d -empty<br />
./test 1<br />
./test _ 3<br />
</code></p>
<p>Only directory &#8220;test2&#8243; was deleted. To delete the rest of the directories when they contain &#8220;special&#8221; characters like whitespace and quotes one needs to modify the command like this:</p>
<p><code>%find -type d -empty -print0 | xargs -0 rm -rvf<br />
removed directory: `./test 1'<br />
removed directory: `./test _ 3 '</code></p>
<p> <img src='http://www.void.gr/kargig/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2009/04/16/delete-all-empty-directories-using-xarg/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
