find /data/files -type f -name "*.txt" -mtime +7 -exec rm {} \;
/data/files - directory
-type f - find files, not directories, etc
-name "*.txt" - specify file type if necessary
-mtime +7 - modified 7 days or more. Last accessed time is -atime
-exec rm {}\; - execute rm with the results returned from 'find'
OR
find /data/files -type f -name "*.txt" -mtime +7 | xargs rm
/data/files - directory
-type f - find files, not directories, etc
-name "*.txt" - specify file type if necessary
-mtime +7 - modified 7 days or more. Last accessed time is -atime
-exec rm {}\; - execute rm with the results returned from 'find'
OR
find /data/files -type f -name "*.txt" -mtime +7 | xargs rm
No comments:
Post a Comment