Link to home
Start Free TrialLog in
Avatar of deriklogov
deriklogov

asked on

Remove files in unix

Hello,

Could you please tell me how to find all image files which older than 3 monthes in specific directory and in all subdirectories
Avatar of amitnepal
amitnepal
Flag of United States of America image

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
ASKER CERTIFIED SOLUTION
Avatar of sandeshj
sandeshj
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start 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.
Avatar of Deepak Sharma
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.