是否可以让 rsync 读取要从活动脚本中的数组而不是随附文件中包含的文件列表?
## declare an array variable
declare -a files=("path" "path" "path")
rsync --files-from=${files[@]} source destination
Run Code Online (Sandbox Code Playgroud)
有一个更好的方法吗?我只想管理一个脚本文件。
您可以执行:
`rsync --files-from=<( printf "%s\n" "${files[@]}" ) source destination
Run Code Online (Sandbox Code Playgroud)
<()将打开一个管道并用内部命令的内容填充它。它返回一个文件描述符
printf "%s\n" "${files[@]}" 在不同的行中回显每个文件名
| 归档时间: |
|
| 查看次数: |
1064 次 |
| 最近记录: |