I have a folder with thousands of subfolders named numerically (from 1 to 200000)
I would like to delete all the folders (and files inside of them) which are named 100000+
Is there a way to do this from a linux command line?
There are several ways to do this, but the simplest is probably:
rm -r [1-2][0-9][0-9][0-9][0-9][0-9]
I would advise you to put an echo
in front of the rm
first, just to make sure that it is finding the directories you really want to remove.
It is possible you may run out of memory for the command line, in which case you may need to use:
for f in [1-2][0-9][0-9][0-9][0-9][0-9]; do rm -r $f; done
Yes, assuming a POSIX shell, use shell pattern matching:
rm -rf *???????
in that directory. Note that this matches any file or subdirectory with 7 or more characters, so be careful!