开发者

Two Questions on for Rsync - rsync by date and by file name

开发者 https://www.devze.com 2022-12-28 06:49 出处:网络
I have two questions with respect to rsync: 1:I have a bunch of files which are incremented by day of the year.Ex:file.txt.81, file.txt.82, etc.Now, these files are in different directories:

I have two questions with respect to rsync:

1: I have a bunch of files which are incremented by day of the year. Ex: file.txt.81, file.txt.82, etc. Now, these files are in different directories:

data1/file.txt.81 data1/file.txt.82 data2/file2.txt.81 data2/file2.txt.82

How can I have rsync get only the *.开发者_如何学C82 files and not even touch the other files

2: Now I have a similar data directory structure as above. How can I rsync all files that have been modified on or after a specific day?

Thanks


Here is the answer for #1rsync -avz --include "**/" --include=*.82 --exclude=* /path/from /path/to

This will recursively (-a) include the directories and search them for anything matching .82 and exclude everthing else. You can find more info on this in man rsync and look for "exclude patterns"

For #2 I would find some way to do it with find and mtime. To find files modified in past 60 minutes with the name *.82 this should work: sudo find /path/from -mmin 60 -type f -name *.82

EDITED: too many backticks

0

精彩评论

暂无评论...
验证码 换一张
取 消