开发者

mirror to a transformed files' structure

I'd like to synchronize a files str开发者_运维百科ucture to another, but transformed one, eg:

filesStructureA/ --[transformation(T)]--> filesStructureB/

Is it possible doing this with rsync? I saw rsync accept a list of files as input (--files-from), but don't really know how to apply the transformation T for each of one...

In other words, is it possible with rsync to rename files on the fly ?

Thank you.

for an example, from src/ to dst/, suppress every bar/ occurences in the destination path, eg:

src/foo/hi.txt
src/foo/bar/hey.txt
src/foo/bar/bar/lorem/bar/hoy.txt

sed 's/bar\///'          <- [Transformation function]

dst/foo/hi.txt
dst/foo/hey.txt
dst/foo/lorem/hoy.txt


Answer is pax:

cd src/
find . -type -f -path '*bar/*' -print0 | pax -0 -rw -v -Y -Z -s '/\/bar//g' ../dst/
cd ..
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜