我正在尝试在 bash 脚本中使用 smbclient 在远程 Windows 服务器上创建一个目录。
虽然这有效:
smbclient -U "DOMAIN/$username" "//remoteserver/folder with spaces" --directory "Another folder with spaces/" -c "mkdir /newfolder/"
这不会:
smbclient -U "DOMAIN/$username" "//remoteserver/folder with spaces" --directory "Another folder with spaces/" -c "mkdir /folder to create with spaces/"
相反,会创建一个简单地称为“文件夹”的文件夹。我尝试过很多变体,如下所示:
"mkdir /folder\ to\ create\ with\ spaces/"
"mkdir '/folder to create with spaces/'"
'mkdir '/folder to create with spaces/''
但似乎找不到神奇的组合。
答案1
这些选项应该有效:
-c 'mkdir "folder to create with spaces"'
-c "mkdir \"folder to create with spaces\""