我有一个 rsync 用作 --files-from 的文件:
dir1
dir2
dir3
Run Code Online (Sandbox Code Playgroud)
我希望能够像这样在每个目录条目上方添加注释:
# my dir1 comment
dir1
#dir2 comment
dir2
#yet another comment
dir3
Run Code Online (Sandbox Code Playgroud)
但 rsync 抱怨“没有这样的文件或目录”
到目前为止,我已经尝试过 #,//,--,,SPACE
有没有办法注释掉/禁用条目?
rob*_*7cc 18
根据man页面rsync:
"... FILE 中的空行和以 ';' 开头的行 或 '#' 被忽略..."
我只是跑了一个快速测试,确实#和;行会被忽略。
Dom*_*Dom 10
做一个grep -v '^#' file > /tmp/filetmp然后启动你的rsync/tmp/filetmp
根据您的 shell,您可以避免使用临时文件(这在 Bash 中有效):
rsync --files-from <(grep -v '^#' file) …
Run Code Online (Sandbox Code Playgroud)
看起来很奇怪的<( … )语法就是 Bash 所说的进程替换。