Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
When I want to just delete files, I'll usually add a -type f so it doesn't remove directories I want to keep in place, just a little extra precaution I use.
-15 (as the first poster suggested) means "less than 15 days ago". 15 (as I accidentally wrote) means "exactly 15 days ago", that is 15 24-hour periods, omitting any fractional part. Obviously it should have been "more than 15 days ago", i.e.
Code:
find directory -type f -mtime +15 | xargs rm
Taking trickyid's advice. BTW, while experimenting, rm -i is safer than rm.
If resource consumption is no problem, go with -exec.
You can limit the length of the command line / argument list by using the option --max-chars or --max-args or --max-lines to xargs. It will then invoke rm repeatedly, but you'll still save, because it can remove many files at a time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.