2
Possible Duplicate:
How to delete all files in a directory except some?
I often face this problem. I have a set of files in a folder and would like to delete all of them except a few.
For example: I have files named according to the date of creation (like 11-1-11.tar, 10-1-11.tar and so on). Now I would like to delete files like 10-1-11, 9-1-11 and so on but not some other files. Basically I would like to enforce what all should be deleted and what should be retained. How would I do this?
You might also want to carefully consider whether you want to use
-r
(recursive) (and perhaps-f
(force)) when you're feeding filenames toxargs
forrm
. – Paused until further notice. – 2011-01-12T02:22:10.840