<?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>delete file on linux &#8211; lifeLinux: Linux Tips, Hacks, Tutorials, Ebooks</title>
	<atom:link href="https://lifelinux.com/tag/delete-file-on-linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://lifelinux.com</link>
	<description>All About Linux !</description>
	<lastBuildDate>Tue, 23 Nov 2010 10:44:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.5.3</generator>
	<item>
		<title>Delete Files Older Than x Days</title>
		<link>https://lifelinux.com/delete-files-older-than-x-days/</link>
					<comments>https://lifelinux.com/delete-files-older-than-x-days/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 23 Nov 2010 08:38:33 +0000</pubDate>
				<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[delete file on linux]]></category>
		<category><![CDATA[delete files older]]></category>
		<category><![CDATA[delete old file order n day]]></category>
		<category><![CDATA[rm command]]></category>
		<guid isPermaLink="false">http://www.lifelinux.com/?p=45</guid>

					<description><![CDATA[<p>The find utility on linux allows you to pass in a bunch of interesting arguments, including one to execute another command on each file. We’ll use this in order to figure out what files are older than a certain number of days, and then use the rm command to delete them. Command Syntax: find /path/to/files* -mtime [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://lifelinux.com/delete-files-older-than-x-days/">Delete Files Older Than x Days</a> appeared first on <a rel="nofollow" href="https://lifelinux.com">lifeLinux: Linux Tips, Hacks, Tutorials, Ebooks</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p></p><p>The find utility on <strong>linux</strong> allows you to pass in a bunch of  interesting arguments, including one to execute another command on each  file. We’ll use this in order to figure out what files are older than a  certain number of days, and then use the rm command to delete them.<span id="more-45"></span></p>
<p><strong>Command Syntax:</strong></p>
<pre>find /path/to/files* -mtime  x -exec rm {} ;</pre>
<p>Note that there are spaces between rm, {}, and ;</p>
<p><strong>Example:</strong></p>
<pre>find /path/to/files* -mtime +7 -exec rm {} ;</pre>
<p><strong>Explanation:</strong></p>
<ul>
<li>The first argument is the path to the files. This can be a path, a  directory, or a wildcard as in the example above. I would recommend  using the full path, and make sure that you run the command without the  exec rm to make sure you are getting the right results.</li>
<li>The second argument, -mtime, is used to specify the number of days  old that the file is. If you enter +7, it will find files older than 7  days.</li>
<li>The third argument, -exec, allows you to pass in a command such as rm. The {} ; at the end is required to end the command.</li>
</ul>
<p>This should work on Ubuntu, Suse, Redhat, CentOS or pretty much any version of linux.</p>
<p><strong>More:</strong></p>
<p>If you happen to get an error:</p>
<pre>/usr/bin/find argument list too long</pre>
<p>You try again with the following command:</p>
<pre>find /path/to/files* -type f -mtime +7 -print 0 | xargs -0 -rm</pre>
<g:plusone href="https://lifelinux.com/delete-files-older-than-x-days/" size="standard"  annotation="none"   ></g:plusone><p>The post <a rel="nofollow" href="https://lifelinux.com/delete-files-older-than-x-days/">Delete Files Older Than x Days</a> appeared first on <a rel="nofollow" href="https://lifelinux.com">lifeLinux: Linux Tips, Hacks, Tutorials, Ebooks</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lifelinux.com/delete-files-older-than-x-days/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
