| Find Command Tips and Tricks |
|
|
|
| How To - Find Command |
| Written by Christian Foronda |
| Tuesday, 05 January 2010 08:49 |
|
To List The Files Not Modified Since 365 Days: $ find /somewhere -mtime +365 -exec ls -al {} \;
To Remove The Files That Are Not Modified Since 365 Days: verify the dates: $ find /somewhere -mtime +365 -mtime -700 -exec ls -al {} \;
permanently remove the files: $ find /somewhere -mtime +5 -mtime -700 -exec rm {} \;
NOTE: "-mtime -2" means files that are less than 2 days old, such as a file that is 0 or 1 days old.
Compress Files Found With Find: $ find dir/ -name '*.txt' | tar -c --files-from=- | bzip2 > dir_txt.tar.bz2
Find + Rsync Find Files 1060 Days Ago And Rsync It To Remote Server /home/archiver/storage/dir $ find /dir -type f -mtime +1060 -print0 | rsync -av --files-from=- --from0 ./ -e ssh archiver@remoteserver:/home/archiver/storage/dir
Find Files By Filenames And Rsync It To Remote Server /home/archiver/storage/dir $ find /dir -type f -iname "200911*" -print0 | rsync -av --files-from=- --from0 ./ -e ssh archiver@remoteserver:/home/archiver/storage/dir
Find + Tar $ find outgoing/ -type f -name "*.txt" | tar -c --files-from=- | bzip2 > archive.tar.bz2
Similar articles |
| Last Updated on Wednesday, 18 May 2011 09:03 |


