我scp
过去经常将文件从Android传输到MacBook,而工作原理却非常有趣。但是我John's folder
在MacBook上有一个文件夹,因此当我尝试在该目录中复制文件时,例如scp [email protected]:/Users/macbook/desktop/John\'s\ folder/file storage/folder
它抛出一个错误
unexpected EOF error while looking for matching \`’\`
和
unexpected end of file
我该如何解决?
这很有趣。我看到的其他答案是告诉您将逸出的引号和逸出的空间换成带引号的字符串。实际上,它们是等效的,因此您将看不到任何变化(a\'\ b
shell与相同"a' b"
)。
这里的问题在于,scp
在远程系统上,解释所给出的命令行的方式。
例如,这将起作用:
scp John\'s\ folder/file localhost:/tmp/dst
但这会失败:
scp localhost:/tmp/src/John\'s\ folder/file /tmp/dst
(我已用于localhost
示例;您应根据user@host
情况使用。)
如果在上面加上-v
(verbose)标志,则scp
可以确切地看到发生了什么事情,这会导致失败:
debug1: Sending command: scp -v -f /tmp/src/John's folder/file
bash: -c: line 0: unexpected EOF while looking for matching `''
bash: -c: line 1: syntax error: unexpected end of file
这里不幸的解决方案是您需要两次转义特殊字符(包括空格)-一次转义为本地shell,一次转义为远程shell:
scp localhost:"/tmp/src/John\'s\ folder/file" /tmp/dst
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句