如何从源复制文件
/backup/cpbackup/daily/a1/public_html/index.html
/backup/cpbackup/daily/b2/public_html/index.html
/backup/cpbackup/daily/c3/public_html/index.html
/backup/cpbackup/daily/d4/public_html/index.html
/backup/cpbackup/daily/e5/public_html/index.html
/backup/cpbackup/daily/f6/public_html/index.html
到目的地
/home/a1/public_html/index.html
/home/b2/public_html/index.html
/home/c3/public_html/index.html
/home/c4/public_html/index.html
/home/e5/public_html/index.html
/home/f6/public_html/index.html
答案1
另一种方法(假设您要复制所有文件):
rsync -a /backup/cpbackup/daily/user* /home/
如果你只想要 index.html 而不需要其他内容:
rsync -av --include=*/ --include=*public_html/index.html --exclude=* /backup/cpbackup/daily/user* /home/
答案2
这是一种解决方法:
for user in user1 user2 user3 user4 user5 user6; do
cp /backup/cpbackup/daily/$user/public_html/index.html /home/$user/public_html/
done