在我的 bash shell 脚本中,
rsync -a --delete -e "ssh -i /keypath" /source_dir/ username@remotehost:/dest_dir/
上面的任何组合[eval,双引号到单引号]都会给出以下错误,
remote-shell 命令中缺少尾随-'。rsync 错误:../main.c(335) [sender=2.6.8] 处的语法或使用错误(代码 1)
但同样的命令直接在命令提示符下工作。任何人都可以帮助我在这里缺少什么
谢谢
您的问题在于 bash 脚本中的嵌入引号。
请参阅以下解决方案(如果您觉得有用,请点赞):
https://superuser.com/questions/354361/rsync-complaining-about-missing-trailing-in-a-bash-script
不知道你的问题是什么,但对我来说,大多数奇怪的 rsync 错误是由登录时输出的.bashrcor .bash_profile(或其他 shell rc 文件)引起的。现在我通常将以下语句写为我的and的第一行:.bashrc.bash_profile
# return if it's not an interactive shell
[[ $- == *i* ]] || return 0
一个对我有用的简单解决方案是使用单引号而不是双引号,即
rsync -a --delete -e 'ssh -i /keypath' /source_dir/ username@remotehost:/dest_dir/