<br>
one can also use '-maxdepth' option of 'find' command to limit the depth of search<br>
for example,<br>
to search only in /path and not in /path/childir, then<br>
<br>
find ./ -name "file-name-pattern" -maxdepth 1 <br>
<br>
otherwise it will search all dirs present in /path<br>
<br>
<br><br><div><span class="gmail_quote">On 3/9/07, <b class="gmail_sendername">Matthew Flaschen</b> <<a href="mailto:matthew.flaschen@gatech.edu">matthew.flaschen@gatech.edu</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Carsten Aulbert wrote:<br>> Gabriel Dragffy wrote:<br>><br>>> Could some one provide me with a sample script that I could run as a<br>>> cron job and it would go through the streamripper folder deleting files
<br>>> older than 1 week (for example). Many thanks.<br>><br>>> gabe<br>><br>><br>> Again, use with care ;)<br>><br>> find /path -name "stream*.mp3" -mtime +6 | xargs -i rm -f {}<br>
><br>> That should delete all files named "stream*.mp3" found in the directory<br>> hierarchie /path with modification date older than 6 days.<br>><br>> For mor info, please read the man page of find, xargs and rm and try the
<br>> stuff first with 'echo' instead of rm to make sure you don't delete<br>> anything you don't want to delete.<br><br>Why do you use xargs? find is designed to do the same thing with just<br>-delete:
<br><br>find -name "stream*.mp3" -mtime +6 -delete<br><br>In general, you could just do:<br><br>find -name "stream*.mp3" -mtime +6 -execdir rm '{}' '+'<br><br>Also, the '+' means it uses the same command line for multiple files,
<br>which is more efficient.<br><br>For testing:<br><br>find -name "stream*.mp3" -mtime +6 -print<br><br>No need to read two man pages. :)<br><br>Matt Flaschen<br><br>--<br>ubuntu-users mailing list<br><a href="mailto:ubuntu-users@lists.ubuntu.com">
ubuntu-users@lists.ubuntu.com</a><br>Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-users">https://lists.ubuntu.com/mailman/listinfo/ubuntu-users</a><br></blockquote></div><br>
<br clear="all"><br>-- <br>Sagittarius<br><br>"Darkness of this UNIVERSE has many secrets."