Tuesday, December 2, 2014

Linux find command for files or folders older than .....

Find files and folders in current working directory older than 60 days
find ./* -maxdepth 0 -mtime +60

Find only folders in /mnt/media -> child folder -> grandchild exclude these folder notme, dtran, xXXx older than 3 years
find /mnt/media -maxdepth 2 -mtime +1095 -type d -not \( -path "./notme*" -o -path "./dtran*" -o -path "./xXXx*" \) > ~/Folder2Backup.txt

Remove all files that have xxx in names and older than 2 years
find ./ -type f -name "*xxx*.*" -mtime +730 -exec rm "{}" \;

Windows not a big deal, install Cygwin and Finding Nemoooo
find /cygdrive/f -maxdepth 2 -type d -mtime +730 > ~/dir_older_than_2years.txt

Find directory older than 2 years and list its size
find /cygdrive/f -maxdepth 1 -type d -mtime +730 -exec du -sh "{}" \; 

0 comments:

Post a Comment