fromのディレクトリにスラッシュ付けるときと付けないときで挙動がかわるのですが、挙動が直感的じゃなくて、はまるんですよね。
まとめ
- スラッシュを付けないと:そのディレクトリがdestinationに作成される
- スラッシュを付けると:そのディレクトリの中身がdestinationに作成される
% mkdir from
% mkdir -p from/001/010/100
% mkdir -p from/002/010/100
% rsync -aru from /tmp/dest/
% tree /tmp/dest
/tmp/dest
└── from
├── 001
│ └── 010
│ └── 100
└── 002
└── 010
└── 100
7 directories, 0 files
% rm -rf /tmp/dest
% rsync -aru from/ /tmp/dest/
% tree /tmp/dest
/tmp/dest
├── 001
│ └── 010
│ └── 100
└── 002
└── 010
└── 100
6 directories, 0 files
%


Comments