How to delete all files older than 3 days when "Argument list too long"? How to delete all files older than 3 days when "Argument list too long"? linux linux

How to delete all files older than 3 days when "Argument list too long"?


To delete all files and directories within the current directory:

find . -mtime +3 | xargs rm -Rf

Or alternatively, more in line with the OP's original command:

find . -mtime +3 -exec rm -Rf -- {} \;


Can also use:

find . -mindepth 1 -mtime +3 -delete

To not delete target directory


Another solution for the original question, esp. useful if you want to remove only SOME of the older files in a folder, would be smth like this:

find . -name "*.sess" -mtime +100 

and so on.. Quotes block shell wildcards, thus allowing you to "find" millions of files :)