[英]Need to move files locally using rsync in bash script
can you please help me on below files having spaces in name are not copying need some help.你能帮我解决以下名称中有空格的文件没有复制需要一些帮助吗?
rsync \
-avhs \
--protect-args \
--remove-source-files \
--info=progress2 \
`find $sourcepath -daystart -mtime 2 -type f` \
$bavkuppath
Assuming you want all the filenames substituted into your command line exactly the same way that command substitution would do it --假设您希望将所有文件名替换到命令行中的方式与命令替换的方式完全相同——
#!/usr/bin/env bash
# ^^^^ this MUST be run with bash, not sh
# obvs, fill these in with your real locations
sourcepath=/some/where
bavkuppath=/else/where
readarray -d '' sourcepaths < <(
find "$sourcepath" -daystart -mtime 2 -type f -print0
)
rsync \
-avhs \
--protect-args \
--remove-source-files \
--info=progress2 \
"${sourcepaths[@]}" \
"$bavkuppath"
It may be better, however, to tell rsync to read the list of paths to copy from a file , and have that file be a process expansion written by find
.然而,告诉 rsync从文件中读取要复制的路径列表,并让该文件成为由
find
编写的进程扩展可能会更好。 In this case, your command would look like:在这种情况下,您的命令将如下所示:
rsync \
-avhs \
--protect-args \
--remove-source-files \
--info=progress2 \
--from0 \
--files-from <(find "$sourcepath" -daystart -mtime 2 -type f -print0) \
"$bavkuppath"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.