remove files from subfolders without the last three
<p>I have a structure like that:</p>

<pre><code>/usr/local/a/1.txt
/usr/local/a/2.txt
/usr/local/a/3.txt
/usr/local/b/4.txt
/usr/local/b/3.txt
/usr/local/c/1.txt
/usr/local/c/7.txt
/usr/local/c/6.txt
/usr/local/c/12.txt
...
</code></pre>

<p>I want to delete all the files *.txt in subfolders except the last three files with the greatest modification date, but here I am in current directory</p>

<pre><code>ls -tr *.txt | head -n-3 |xargs rm -f
</code></pre>

<p>I need to combine that with the code:</p>

<pre><code>find /usr/local/**/* -type f 
</code></pre>

<p>Should I use the maxdepth option?</p>

<p>Thanks for helping,
aola</p>