Bulk remove a large amount of files from a directory
Most people know the command
rm dir/*
It can be dangerous but if you know what is in the target directory and you want to remove all the files, its fine. A problem will creep up however if you have a lot of files in a directory (I'm talking hundreds of thousands, if not millions).
You tend to get this error:
unable to execute /bin/rm: Argument list too long
So a nice workaround is to use the find program with the delete flag
find . -name "dir/*" -delete
This technique works very quickly and generally a better way of working with files in a directory
Written by Christopher Briggs
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Linux
Authors
Related Tags
#linux
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#