To display just modified files we can use command
# find . -type f -mtime 0
where . (dot) means start search from current directory
-type f means find and display only files otherwise directories appear also in the list
-mtime 0 means modify time was within last 24 hours
It looks good so far? Let’s continue.
# find . -type f -mtime 0 | xargs tar -cf /path_to/archive.tar
found filenames will be piped to tar command. Hence archive.tar contains all freshly changed files.
if any filename contains whitespaces it can be correctly handled with small changes
# find . -type f -mtime 0 –print0 | xargs -0 tar -cf /path_to/archive.tar
And what if we need only updated files in the last 10 minutes? It is not a problem at all.
Replace -mtime 0 with –mmin -10
# find . -type f -mmin -10 –print0 | xargs -0 tar -cf /path_to/archive.tar
Enjoy!
No comments:
Post a Comment