I've got a script that scp's a file from remote host back to local. Sometimes the file names contain spaces. scp does not like spaces in its file names. For some reason my attempts at handling the spaces have not resulted in the correct scp path.Code:PATH=/var/root/Documents/MyFile OG-v1.2.3.pkgscp $PATH Me@10.1.10.33:/Users/Me/DesktopResults inCannot find directory: var/root/Documents/MyFileCannot find directory: OG-v1.2.3.pkgEnclosing PATH in quotes $PATH gives the same error.Swapping the spaces for escaped spaces also is not working, although as far as I can tell it should:ESC_PATH=${PATH/' '/'\ '}although printing the escaped path shows that the edit worked:echo $ESC_PATH> /var/root/Documents/MyFile\ OG-v1.2.3.pkg
Trouble in script with spaces in filename
bash;shell;scripting;quoting;escape characters
You should quote both the declaration and the usagePATH=/var/root/Documents/MyFile OG-v1.2.3.pkgscp $PATH Me@10.1.10.33:/Users/Me/DesktopIf you do not quote the first, $PATH will contain just the first part. If you do not quote the second, scp will treat each space-separated part as an argument.