Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

find

bash

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.

like image 951
cmac68 Avatar asked Dec 09 '14 05:12

cmac68


1 Answers

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.

like image 84
William Pursell Avatar answered Oct 06 '22 19:10

William Pursell