How do I escape spaces in path for scp copy in Linux?

后端 未结 6 633
抹茶落季
抹茶落季 2020-11-30 17:13

I\'m new to linux, I want to copy a file from remote to local system... now I\'m using scp command in linux system.. I have some folders or files names are with spaces, when

6条回答
  •  天命终不由人
    2020-11-30 17:26

    works

    scp localhost:"f/a\ b\ c" .
    
    scp localhost:'f/a\ b\ c' .
    

    does not work

    scp localhost:'f/a b c' .
    

    The reason is that the string is interpreted by the shell before the path is passed to the scp command. So when it gets to the remote the remote is looking for a string with unescaped quotes and it fails

    To see this in action, start a shell with the -vx options ie bash -vx and it will display the interpolated version of the command as it runs it.

提交回复
热议问题