Our project team uses a script which creates thousands of files in a folder and we sometime has to manually clean up all those files.
rm command failed saying the list is too long and we had to find another method to do this. rather than writing s shell script and delete the files one by one we used the find command.
Here how we had done it.
>>>ls -lrt| wc -l 250,002
We have 250K files in this directory and we tried removing them using the rm command.
>>> rm *.env ksh: rm: /bin/rm: cannot execute [Argument list too long]
This issue can be easily solved by the find command and we noticed find runs faster in such situations.
>>>find . -name "*.env" -delete
Above listed find command deleted all .env files in the current directory.