I've a directory structure which looks like this
main
-in
infile1.txt
infile2.txt
-out
outfile1.txt
outfile2.txt
-log
logfile1.txt
logfile2.txt
how can I delete files in all the sub directories which are 15 days old.
I know I can use following commands, but I want to do it using a single command.
find in/* -mtime +15 -exec rm {} \;
find out/* -mtime +15 -exec rm {} \;
find log/* -mtime +15 -exec rm {} \;
find允许多个起点,所以你可以这样做:
find in out log -mtime +15 -exec rm {} \;
There is a Unix/Linux Stack Exchange...where I found this:
https://unix.stackexchange.com/questions/136804/cron-job-to-delete-files-older-than-3-days
Seems similar to what you are looking for.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.