无法通过变量将带有 space 的文件名传递给 SCP 命令

Unable to pass filename with space through variable to SCP command

我正在尝试将变量 $file 设置为 "Unavailable Voucher's Report_Apr-2017.txt"。它已成功设置为变量。但是当我在脚本中的 SCP 命令中使用此变量时出现错误。我试过把' '(space)换成'\ '(转义space),还是没用。

[***]# scp $file user@remoteserver:/path

错误如下:

Unavailable\: No such file or directory
Voucher's\: No such file or directory
Report_Apr-2017.txt: No such file or directory

尝试双引号变量:

file="Unavailable Voucher's Report_Apr-2017.txt"
scp "$file" user@remoteserver:/path