【发布时间】:2018-01-02 20:02:32
【问题描述】:
我将这些 JSON 文件放在一个大目录结构中。有些只是“abc.json”,有些是添加的“.finished”。我只想 rsync 没有“.finished”的文件。
$ find
.
./a
./a/abc.json.finished
./a/abc.json <-- this file
./a/index.html
./a/somefile.css
./b
./b/abc.json.finished
./b/abc.json <-- this file
复制所有“abc.json”和“abc.json.finished”的示例 rsync 命令。我只想要“abc.json”。
$ rsync --exclude="finished" --include="*c.json" --recursive \
--verbose --dry-run . server:/tmp/rsync
sending incremental file list
created directory /tmp/rsync
./
a/
a/abc.json
a/abc.json.finished
a/index.html
a/somefile.css
b/
b/abc.json
b/abc.json.finished
sent 212 bytes received 72 bytes 113.60 bytes/sec
total size is 0 speedup is 0.00 (DRY RUN)
更新:在文件夹中添加了更多文件。我的场景中存在 HTML 文件、CSS 和其他文件。只应传输以“c.json”结尾的文件。
可以使用以下命令重新创建场景:
mkdir a
touch a/abc.json.finished
touch a/abc.json
touch a/index.html
touch a/somefile.css
mkdir b
touch b/abc.json.finished
touch b/abc.json
【问题讨论】:
标签: rsync