Remove files in unix


Could you please tell me how to find all image files which older than 3 monthes in specific directory and in all subdirectories
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

find / -name '*.jpg' -atime 90

you can replace / by your directory path and jpg with image extensions that you want to look for.

Hope this helps
find /path/dir -name '*.jpg' -mtime +90 -delete

This would delete all jpg files modified more than 3 months back.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
did you wanted to delete ?

atime is to look by access time

and mtime is to look by modification time.

you can use as per your requirement.
find /dir -name '*.jpg' -atime +90 -exec rm -rf {} \;

But to confirm you can slightly modify this as:

find /dir -name '*.jpg' -atime +90 -exec ls -ld {} \; >> /tmp/any_file
cat /tmp/any_file
so now if you want you can directly execute the first step or you can select the particular files from /tmp/any_file for selected removal.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.