views:

90

answers:

3

Hello all,

I have the following command which deletes files that are one day old and that are of mp3 file type.

    find /home/get/public_html/audio -daystart -maxdepth 1 -mtime +1 
    -type f -name "*.mp3" |xargs rm -f

The problem with this is when i run it, it sometimes says "fork": resource xargs not available.

Does this mean, this command first finds the file and then starts many process to delete each file?

Can someone help me re-write this, so that when a file is found, it is immediatly deleted rather than being piped to xargs?

Thanks all

EDIT:

find: invalid predicate `-delete' - I can't use that!

A: 

Check your man page for find, it might support -delete, making it as simple as

find /home/get/public_html/audio -daystart -maxdepth 1 \
   -mtime +1 -type f -name "*.mp3" -delete
Paul Dixon
A: 

Perhaps you can use the "-delete" flag to find, instead of piping to xargs?

+2  A: 

what about trying:

 find /home/get/public_html/audio -daystart -maxdepth 1 -mtime +1 
    -type f -name "*.mp3" -exec rm -f {} \;
Tree77