How to Delete large amount of files in directory
So you have clearly got a very large amount of files!
If you issue the conventional rm -rf * within the directory, you will get an error -bash: /bin/rm: Argument list too long.
This happens because the shell expands the * glob into individual arguments, and there’s a kernel limit on how many arguments a single command can take. I hit this on a server with millions of log files that hadn’t been rotated in months.
You can still easily remove these files, just make sure to use the find command instead!
Solution:
find . -type f -delete
There’s a longer note on cli over here.
The find command processes files one at a time internally, so it doesn’t hit the argument limit. If you want to be more selective, you can add filters like -name "*.log" or -mtime +30 to only delete files matching certain criteria. For directories, use -type d with -empty to clean up leftover empty folders afterward.