cmac68
cmac68

Reputation: 95

/usr/bin/find: Argument list too long, getting this while trying to delete 164850 files

Here is the script

#!/bin/bash  
find /mnt/blah/DB/* -mtime +65 | xargs rm -Rf "{}" \; 

I have also tried the following, but neither works and both get the error as per the title.

find /mnt/blah/DB/* -mtime +35 -exec rm {} \;

All help greatly appreciated.

Upvotes: 9

Views: 26968

Answers (1)

William Pursell
William Pursell

Reputation: 212268

Just drop the * and do:

find /mnt/blah/DB -mtime +35 -type f -exec rm {} \;

Listing only the top level directory of the directory tree you want to operate on will be sufficient.

Upvotes: 36

Related Questions